I have a vbs file that usese a wscript shell to modify registry keys on a
remote machine. It works fine if I have the shell only change one key, but
as soon as I try to change multiple keys in the same shell it simply doesn't
work.

Here's what works:
regforce = "reg add ""\\" & strIP & "\HKLM\SOFTWARE\Microsoft\Windows NT\" &
_
"CurrentVersion\Winlogon"" /v ForceAutoLogon /t REG_SZ /d 1 /f"

objShell.Run regforce,0


Here's what doesn't work:
regboth = "reg add ""\\" & strIP & "\HKLM\SOFTWARE\Microsoft\Windows NT\" &
_
"CurrentVersion\Winlogon"" /v ForceAutoLogon /t REG_SZ /d 1 /f" & _
"reg add ""\\" & strIP & "\HKLM\SOFTWARE\Microsoft\Windows NT\" & _
"CurrentVersion\Winlogon"" /v AutoAdminLogon /t REG_SZ /d 1 /f"

objShell.Run regboth,0

When I try running regboth, neither key gets modified. But if I run either
'reg add' statement by itself it works fine, so the problem seems to be in
the way I'm combining the two statements. I know the '&' character is
supposed to allow multiple commands to be run from a single shell, but it
just isn't working. Anyone know what I'm doing wrong?

Thanks in advance for any help with this...

Re: Syntax to run multiple commands in a single shell by Mark

Mark
Tue Mar 15 16:04:39 CST 2005

the '&' character is a command separator for commands sent to cmd.exe and
WScript.Shell does not use cmd.exe for processing commands.

so, you can either run both commands separately, or you can prepend "cmd.exe
/c" to the front of the regboth string. if you choose to do this, you may
also have to adjust the number / placement of the quote characters in your
command.

hope this helps,
mark



"D.P. Roberts" <dproberts@pbride.com> wrote in message
news:%23gJbogaKFHA.1396@TK2MSFTNGP10.phx.gbl...
>I have a vbs file that usese a wscript shell to modify registry keys on a
>remote machine. It works fine if I have the shell only change one key, but
>as soon as I try to change multiple keys in the same shell it simply
>doesn't work.
>
> Here's what works:
> regforce = "reg add ""\\" & strIP & "\HKLM\SOFTWARE\Microsoft\Windows NT\"
> & _
> "CurrentVersion\Winlogon"" /v ForceAutoLogon /t REG_SZ /d 1 /f"
>
> objShell.Run regforce,0
>
>
> Here's what doesn't work:
> regboth = "reg add ""\\" & strIP & "\HKLM\SOFTWARE\Microsoft\Windows NT\"
> & _
> "CurrentVersion\Winlogon"" /v ForceAutoLogon /t REG_SZ /d 1 /f" & _
> "reg add ""\\" & strIP & "\HKLM\SOFTWARE\Microsoft\Windows NT\" & _
> "CurrentVersion\Winlogon"" /v AutoAdminLogon /t REG_SZ /d 1 /f"
>
> objShell.Run regboth,0
>
> When I try running regboth, neither key gets modified. But if I run either
> 'reg add' statement by itself it works fine, so the problem seems to be in
> the way I'm combining the two statements. I know the '&' character is
> supposed to allow multiple commands to be run from a single shell, but it
> just isn't working. Anyone know what I'm doing wrong?
>
> Thanks in advance for any help with this...
>