Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quote problem in script with logonserver 2

Status
Not open for further replies.

utilman

IS-IT--Management
Dec 25, 2002
35
NL
I know it's a well known problem, but I tried every option I knew and cannot find the right solution...

Can someone help me out, and tell me where I went wrong?



Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshProcessEnvironment = WshShell.Environment("Process")

LogonServer = WshProcessEnvironment("LogonServer")

WshShell.Run """LogonServer & \netlogon\Delete Registry Value.vbs"""



This doen't work either:
WshShell.Run "" & LogonServer & "\netlogon\Delete DISKIS Registry Value.vbs"""
 
Hello utilman,

Try this
Code:
WshShell.Run chr(34) & LogonServer & "\netlogon\Delete DISKIS Registry Value.vbs & chr(34)
regards - tsuji
 
utilman,may i suggest that during testing you make use of msgbox or wscript.echo

that way you can test what you are passing to WshShell before you pass it, i.e.

Msgbox """ & LogonServer & "\netlogon\Delete DISKIS Registry Value.vbs"""

would have displayed

"LogonServer & "\netlogon\Delete DISKIS Registry Value.vbs"

literally to the screen and this is literally what you are passing to WshShell.Run, therefore the windows SHELL would not have a clue where LogonServer.exe lives,,,because there isnt one

You will be surprised how useful msgbox wscript.echo are, they are not only used to display something to the user
 
Correction:

I'd an obvious typos, missing the closing quote. Here it is the corrected line.
Code:
WshShell.Run chr(34) & LogonServer & "\netlogon\Delete DISKIS Registry Value.vbs[COLOR=red]"[/color] & chr(34)

- tsuji
 
@mrmovie
Thx for this handy tip. I'm a bit new in vbscripting and
this tip is for me a valuable one...

@tsuji
The chr(34) solution worked... thx a lot.
It's a little bit confusing that you can use triple quotes with a unc path with spaces, but if you use a variable you have to use these chr(34) at the beginning and at the end instead of the triple quotes. Still getting used to it if you only now batching methods :)


thx guys !!
 
The Chr(34) is not mandatory, if you prefer triple quotes:
WshShell.Run """" & LogonServer & "\netlogon\Delete DISKIS Registry Value.vbs"""

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
OK.. That without long file name you only need:

WshShell.Run LogonServer & "\netlogon\Delete.vbs"

I understand. That you need the triple quotes or chr(34) with long file names I get too. But what I do not understand is why from

LogonServer &

I have to use

& LogonServer &

So as extra <space>&<space>

It surely has something to do with the long file name and the triple quotes, but I think this is a pretty important basic thing for me to know. Can you clear this up for me ??

Thx again for helping me out with these simple things ;)
 
1) In fact you have to use either
"""" & LogonServer &
or
Chr(34) & LogonServer &
The goal is to surround the whole UNC with quotes
2) The & is the string concatenation operator and &h is the beginning of a hexadecimal constant, so the habbit to always surround & with space to avoid confusion.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
OK.. I'm getting the hang of it a little, so I decided to make a robocopy script with a lot of quotes and (chr(34)
However, I'm still missing one quote I think. Can someone help me out a little, so I hopefully understand the way it works :) I tested it with the Msgbox command.



Set WSHShell = CreateObject("WScript.Shell")
'wshshell.run "C:\WINDOWS\system32\robocopy.exe " & chr(34) & "C:\Program Files\Ad-aware 6\Plugins" & chr(34) & " D:\BACKUP IMPORTANT\Server\Program Files\LiteWeb" & chr(34) & " /MIR /TEE /W:10 /R:3 /LOG:LOGFILE.TXT, 0, Flase"

MsgBox "C:\Windows\robocopy.exe " & chr(34) & "C:\Program Files\Ad-aware 6\Plugins" & chr(34) & " D:\BACKUP IMPORTANT\Server\Program Files\LiteWeb" & chr(34) & " /MIR /TEE /W:10 /R:3 /LOG:LOGFILE.TXT, 0, Flase
 
Try this:
MsgBox "C:\Windows\robocopy.exe " & chr(34) & "C:\Program Files\Ad-aware 6\Plugins" & chr(34) & " [highlight]" & Chr(34) & "[/highlight]D:\BACKUP IMPORTANT\Server\Program Files\LiteWeb" & chr(34) & " /MIR /TEE /W:10 /R:3 /LOG:LOGFILE.TXT, 0, F[highlight]al[/highlight]se"

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
The running commandline be:
Code:
"C:\Windows\robocopy.exe " & chr(34) & "C:\Program Files\Ad-aware 6\Plugins" & chr(34) & " " & chr(34) & "D:\BACKUP IMPORTANT\Server\Program Files\LiteWeb" & chr(34) & " /MIR /TEE /W:10 /R:3 /LOG:LOGFILE.TXT"

- tsuji
 
You guys are right.. an extra pair of " " and & chr(34) & did the trick ;-)
These try outs and examples learned me a lot. Thx again guys for the support !! [thumbsup]


This code works for me:


Set WSHShell = CreateObject("WScript.Shell")
wshshell.run "C:\Windows\System32\robocopy.exe " & chr(34) & "C:\Program Files\Ad-aware 6" & chr(34) & " " & Chr(34) & "D:\BACKUP IMPORTANT\Server\Program Files\Ad-aware" & chr(34) & " /MIR /TEE /W:10 /R:3 /LOG:C:\LOGFILE.TXT"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top