Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Supplying a variable to wshshell.Run

2,223 views
Skip to first unread message

jmedd

unread,
Jun 18, 2008, 7:40:00 AM6/18/08
to
As part of a new login script I am writing I can successfully do the
following if I manually specify the servername:

set wshShell= Wscript.CreateObject("WScript.Shell")
wshshell.Run "regedit /s
\\servername\scripts\outlook\outlook.reg",0,bWaitOnReturn

What I want to be able to achieve is find the Logon DC and use that as the
location to run the .reg file from.

I have the below which succesfully gets the Logon DC for me:

Set WshShell = WScript.CreateObject("WScript.Shell")
LogonDC= WshShell.ExpandEnvironmentStrings("%logonserver%")
wscript.echo LogonDC

which outputs to \\servername

but I can't seem to be able to get the LogonDC variable to work in the
regedit command. I think I may just be missing the syntax for how to provide
it; I am trying along the lines of:

Set WshShell = WScript.CreateObject("WScript.Shell")
LogonDC= WshShell.ExpandEnvironmentStrings("%logonserver%")

set wshShell= Wscript.CreateObject("WScript.Shell")
wshshell.Run "regedit /s logondc\scripts\outlook\outlook.reg",0,bWaitOnReturn

Any help much appreciated!

Tom Lavedas

unread,
Jun 18, 2008, 8:16:42 AM6/18/08
to

The run method needs a string, so you need to construct that string
from the contents of your variable using concatenation ...

' ...
bWaitOnReturn = True
wshshell.Run "regedit /s " & logonDC & "\scripts\outlook
\outlook.reg", _
0,bWaitOnReturn

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

jmedd

unread,
Jun 18, 2008, 9:06:02 AM6/18/08
to
Brilliant stuff, works a treat.

I had the

& logonDC &

earlier, but was missing the extra quotes.


Thanks a lot!

0 new messages