I am trying to create a script that allows a user to start and stop a
service on a remote computer.

I am having troubles with spaces in the command.

Here is what I have so far.
I am having troubles with line following Case "1" and Case "2"

Any advice would be greatly appreciated.


================================================================

Option Explicit

Dim objmenu, username, wshshell, fso
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

Username = InputBox("Enter your admin username (domain\username)",
"Enter Username")
'create an object from the gui_menu class
Set objmenu = New gui_menu
'start the application
objmenu.getInput

Class gui_menu
private Input, quit, strText, cmd, arrMenu, i, return, strProg

Private Sub pickInput
'if you add anything to the menu array below, make sure you
add a corresponding entry here
Select Case Input
Case "1"
cmd = " ""sc \\remotecomputer stop" "Service with spaces in name"""
startProg cmd
WScript.Sleep(22000)
getInput
Case "2"
cmd = " ""sc \\remotecomputer start "Service with spaces in name"""
startProg cmd
getInput
Case "3"
quit = MsgBox ("Are you sure?", 36, "Want To
quit?")'52
If quit = 6 Then
WScript.Quit
Else
getInput
End If
Case ""
quit = MsgBox ("Are you sure?", 36, "Want To
quit?")'52
If quit = 6 Then
WScript.Quit
Else
getInput
End If
Case Else
MsgBox ("That is an incorrect entry, try again")
getInput
End Select
End Sub 'pickInput

Public sub getInput
'add any menu names you want in this array, make sure you
adjust the select/case in pickInput() accordingly
arrMenu = Array("STOP Service","START Service","Quit or click
Cancel")
strText = "Enter selection below." & vbNewLine
'build the menu
For i = 1 To (UBound(arrMenu) + 1)
strText = strText & i & ". " & arrMenu(i - 1) & vbNewLine
Next
Input = InputBox(strText, "Make your selection")
pickInput
End sub 'getInput

Private Sub startProg(cmd)
return = WshShell.Run("%windir%\system32\runas.exe /user:" &
username & cmd, 1, False)
End Sub 'startProg
End Class 'gui_menu
==============================================================

Re: Quoting within already quoted command by Tom

Tom
Wed Mar 19 07:26:15 CDT 2008

On Mar 19, 5:11 am, Shayne <raz...@gmail.com> wrote:
> I am trying to create a script that allows a user to start and stop a
> service on a remote computer.
>
> I am having troubles with spaces in the command.
>
> Here is what I have so far.
> I am having troubles with line following Case "1" and Case "2"
>
> Any advice would be greatly appreciated.
>
> ================================================================
>
> Option Explicit
>
> Dim objmenu, username, wshshell, fso
> Set WshShell = WScript.CreateObject("WScript.Shell")
> Set fso = CreateObject("Scripting.FileSystemObject")
>
> Username = InputBox("Enter your admin username (domain\username)",
> "Enter Username")
> 'create an object from the gui_menu class
> Set objmenu = New gui_menu
> 'start the application
> objmenu.getInput
>
> Class gui_menu
> private Input, quit, strText, cmd, arrMenu, i, return, strProg
>
> Private Sub pickInput
> 'if you add anything to the menu array below, make sure you
> add a corresponding entry here
> Select Case Input
> Case "1"
'
' I believe this is what you need ...
cmd = " ""sc \\remotecomputer stop ""Service with spaces in
name"""""
' Escape the quotes around the service name and then around the
' whole command as well.
> startProg cmd
> WScript.Sleep(22000)
> getInput
> Case "2"
'
' I believe this is what you need ...
cmd = " ""sc \\remotecomputer start ""Service with spaces in
name"""""
' Watch for word wrap. The statement between the comments is all one
' line of code
'
> startProg cmd
> getInput
{snip}
> Private Sub startProg(cmd)
> return = WshShell.Run("%windir%\system32\runas.exe /user:" &
> username & cmd, 1, False)
> End Sub 'startProg
> End Class 'gui_menu
> ==============================================================

See comment inline above ...

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

Re: Quoting within already quoted command by Shayne

Shayne
Wed Mar 19 11:33:28 CDT 2008

On Mar 19, 6:26=A0am, Tom Lavedas <tglba...@cox.net> wrote:
> On Mar 19, 5:11 am, Shayne <raz...@gmail.com> wrote:
>
>
>
> > I am trying to create a script that allows a user to start and stop a
> > service on a remote computer.
>
> > I am having troubles with spaces in the command.
>
> > Here is what I have so far.
> > I am having troubles with line following Case "1" and Case "2"
>
> > Any advice would be greatly appreciated.
>
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> > Option Explicit
>
> > Dim objmenu, username, wshshell, fso
> > Set WshShell =3D WScript.CreateObject("WScript.Shell")
> > Set fso =3D CreateObject("Scripting.FileSystemObject")
>
> > Username =3D InputBox("Enter your admin username (domain\username)",
> > "Enter Username")
> > 'create an object from the gui_menu class
> > Set objmenu =3D New gui_menu
> > 'start the application
> > objmenu.getInput
>
> > Class gui_menu
> > =A0 =A0 private Input, quit, strText, cmd, arrMenu, i, return, strProg
>
> > =A0 =A0 Private Sub pickInput
> > =A0 =A0 =A0 =A0 'if you add anything to the menu array below, make sure =
you
> > add a corresponding entry here
> > =A0 =A0 =A0 =A0 Select Case Input
> > =A0 =A0 =A0 =A0 =A0 =A0 Case "1"
>
> '
> ' I believe this is what you need ...
> =A0 cmd =3D " ""sc \\remotecomputer stop ""Service with spaces in
> name"""""
> ' Escape the quotes around the service name and then around the
> ' whole command as well.> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 startProg cmd
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 WScript.Sleep(22000)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 getInput
> > =A0 =A0 =A0 =A0 =A0 =A0 Case "2"
>
> '
> ' I believe this is what you need ...
> =A0 cmd =3D " ""sc \\remotecomputer start ""Service with spaces in
> name"""""
> ' Watch for word wrap. =A0The statement between the comments is all one
> ' line of code
> '
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 startProg cmd
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 getInput
> {snip}
> > =A0 =A0 Private Sub startProg(cmd)
> > =A0 =A0 =A0 =A0 =A0return =3D WshShell.Run("%windir%\system32\runas.exe =
/user:" &
> > username & cmd, 1, False)
> > =A0 =A0 End Sub 'startProg
> > End Class 'gui_menu
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> See comment inline above ...
>
> Tom Lavedas
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Dhttp://members.cox.net/tglbatch/wsh/- Hid=
e quoted text -
>
> - Show quoted text -

Thanks for the quick response.

I would've thought that as well, but when I do that, the quotes are
singling line termination or command termination.
When I copy you command in, or put quotes between STOP and Service
with Spaces
I get

Script: path to scritpt
Line: 33
Char 56
Errror: Unterminated string constant
Code: 800A0409
Source: Microsoft VBScript compilation error


Re: Quoting within already quoted command by Tom

Tom
Wed Mar 19 12:20:48 CDT 2008

On Mar 19, 12:33 pm, Shayne <raz...@gmail.com> wrote:
> On Mar 19, 6:26 am, Tom Lavedas <tglba...@cox.net> wrote:
>
>
>
> > On Mar 19, 5:11 am, Shayne <raz...@gmail.com> wrote:
>
> > > I am trying to create a script that allows a user to start and stop a
> > > service on a remote computer.
>
> > > I am having troubles with spaces in the command.
>
> > > Here is what I have so far.
> > > I am having troubles with line following Case "1" and Case "2"
>
> > > Any advice would be greatly appreciated.
>
> > > ================================================================
>
> > > Option Explicit
>
> > > Dim objmenu, username, wshshell, fso
> > > Set WshShell = WScript.CreateObject("WScript.Shell")
> > > Set fso = CreateObject("Scripting.FileSystemObject")
>
> > > Username = InputBox("Enter your admin username (domain\username)",
> > > "Enter Username")
> > > 'create an object from the gui_menu class
> > > Set objmenu = New gui_menu
> > > 'start the application
> > > objmenu.getInput
>
> > > Class gui_menu
> > > private Input, quit, strText, cmd, arrMenu, i, return, strProg
>
> > > Private Sub pickInput
> > > 'if you add anything to the menu array below, make sure you
> > > add a corresponding entry here
> > > Select Case Input
> > > Case "1"
>
> > '
> > ' I believe this is what you need ...
> > cmd = " ""sc \\remotecomputer stop ""Service with spaces in
> > name"""""
> > ' Escape the quotes around the service name and then around the
> > ' whole command as well.> startProg cmd
> > > WScript.Sleep(22000)
> > > getInput
> > > Case "2"
>
> > '
> > ' I believe this is what you need ...
> > cmd = " ""sc \\remotecomputer start ""Service with spaces in
> > name"""""
> > ' Watch for word wrap. The statement between the comments is all one
> > ' line of code
> > '
>
> > > startProg cmd
> > > getInput
> > {snip}
> > > Private Sub startProg(cmd)
> > > return = WshShell.Run("%windir%\system32\runas.exe /user:" &
> > > username & cmd, 1, False)
> > > End Sub 'startProg
> > > End Class 'gui_menu
> > > ==============================================================
>
> > See comment inline above ...
>
> > Tom Lavedas
> > ===========http://members.cox.net/tglbatch/wsh/-Hide quoted text -
>
> > - Show quoted text -
>
> Thanks for the quick response.
>
> I would've thought that as well, but when I do that, the quotes are
> singling line termination or command termination.
> When I copy you command in, or put quotes between STOP and Service
> with Spaces
> I get
>
> Script: path to scritpt
> Line: 33
> Char 56
> Errror: Unterminated string constant
> Code: 800A0409
> Source: Microsoft VBScript compilation error

Ok, I just went and looked at the help for runas. It uses a backslash
as the escape character (JScript like). The example was ...

runas /env /user:user@domain.microsoft.com "notepad \"my file.txt\""
note backslash^ and ^

That means the string probably needs to be ...

cmd = " ""sc \\remotecomputer start \"Service with spaces in name
\""""

I hope it doesn't also need to escape backslashes. Another example
given suggests that it does NOT.

Also, AFAIK the user is still going to have to supply the proper
password - which might be problematic. I don't use runas, but IIRC it
does not accept redirection of the password and I don't remember the
WSHShell Run method's console window allowing user interaction. I
don't *know* that is a problem (or have a solution to suggest), but
offer my tiny bit of information for what it's worth.

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

Re: Quoting within already quoted command by Shayne

Shayne
Thu Mar 20 20:11:21 CDT 2008

On Mar 19, 11:20=A0am, Tom Lavedas <tglba...@cox.net> wrote:
> On Mar 19, 12:33 pm, Shayne <raz...@gmail.com> wrote:
>
>
>
> > On Mar 19, 6:26 am, Tom Lavedas <tglba...@cox.net> wrote:
>
> > > On Mar 19, 5:11 am, Shayne <raz...@gmail.com> wrote:
>
> > > > I am trying to create a script that allows a user to start and stop =
a
> > > > service on a remote computer.
>
> > > > I am having troubles with spaces in the command.
>
> > > > Here is what I have so far.
> > > > I am having troubles with line following Case "1" and Case "2"
>
> > > > Any advice would be greatly appreciated.
>
> > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> > > > Option Explicit
>
> > > > Dim objmenu, username, wshshell, fso
> > > > Set WshShell =3D WScript.CreateObject("WScript.Shell")
> > > > Set fso =3D CreateObject("Scripting.FileSystemObject")
>
> > > > Username =3D InputBox("Enter your admin username (domain\username)",=

> > > > "Enter Username")
> > > > 'create an object from the gui_menu class
> > > > Set objmenu =3D New gui_menu
> > > > 'start the application
> > > > objmenu.getInput
>
> > > > Class gui_menu
> > > > =A0 =A0 private Input, quit, strText, cmd, arrMenu, i, return, strPr=
og
>
> > > > =A0 =A0 Private Sub pickInput
> > > > =A0 =A0 =A0 =A0 'if you add anything to the menu array below, make s=
ure you
> > > > add a corresponding entry here
> > > > =A0 =A0 =A0 =A0 Select Case Input
> > > > =A0 =A0 =A0 =A0 =A0 =A0 Case "1"
>
> > > '
> > > ' I believe this is what you need ...
> > > =A0 cmd =3D " ""sc \\remotecomputer stop ""Service with spaces in
> > > name"""""
> > > ' Escape the quotes around the service name and then around the
> > > ' whole command as well.> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 startProg cm=
d
> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 WScript.Sleep(22000)
> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 getInput
> > > > =A0 =A0 =A0 =A0 =A0 =A0 Case "2"
>
> > > '
> > > ' I believe this is what you need ...
> > > =A0 cmd =3D " ""sc \\remotecomputer start ""Service with spaces in
> > > name"""""
> > > ' Watch for word wrap. =A0The statement between the comments is all on=
e
> > > ' line of code
> > > '
>
> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 startProg cmd
> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 getInput
> > > {snip}
> > > > =A0 =A0 Private Sub startProg(cmd)
> > > > =A0 =A0 =A0 =A0 =A0return =3D WshShell.Run("%windir%\system32\runas.=
exe /user:" &
> > > > username & cmd, 1, False)
> > > > =A0 =A0 End Sub 'startProg
> > > > End Class 'gui_menu
> > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> > > See comment inline above ...
>
> > > Tom Lavedas
> > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Dhttp://members.cox.net/tglbatch/wsh/-=
Hidequoted text -
>
> > > - Show quoted text -
>
> > Thanks for the quick response.
>
> > I would've thought that as well, but when I do that, the quotes are
> > singling line termination or command termination.
> > When I copy you command in, or put quotes between STOP and Service
> > with Spaces
> > I get
>
> > Script: path to scritpt
> > Line: 33
> > Char 56
> > Errror: Unterminated string constant
> > Code: 800A0409
> > Source: Microsoft VBScript compilation error
>
> Ok, I just went and looked at the help for runas. =A0It uses a backslash
> as the escape character (JScript like). =A0The example was ...
>
> =A0runas /env /user:u...@domain.microsoft.com "notepad \"my file.txt\""
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0note backslash^ =A0 =A0 =A0 =A0and ^
>
> That means the string probably needs to be ...
>
> =A0cmd =3D " ""sc \\remotecomputer start \"Service with spaces in name
> \""""
>
> I hope it doesn't also need to escape backslashes. =A0Another example
> given suggests that it does NOT.
>
> Also, AFAIK the user is still going to have to supply the proper
> password - which might be problematic. =A0I don't use runas, but IIRC it
> does not accept redirection of the password and I don't remember the
> WSHShell Run method's console window allowing user interaction. =A0I
> don't *know* that is a problem (or have a solution to suggest), but
> offer my tiny bit of information for what it's worth.
>
> Tom Lavedas
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Dhttp://members.cox.net/tglbatch/wsh/

Thanks,
I tried that.
Here are the variations which by the way did not work.

cmd =3D " ""sc \\servername stop \"VMware NAT Service\""""
cmd =3D " ""sc \\servername stop "VMware NAT Service""""
cmd =3D " ""sc \\servername stop \VMware NAT Service\"""


Don't mind the service name, it is the only service I have with
spaces, to experiment on.

As for the password, I am trying to keep it somewhat secure, in the
sense of not having it prefilled in the file. But yet having a user
know it unfortunately.






Re: Quoting within already quoted command by Shayne

Shayne
Thu Mar 20 21:48:38 CDT 2008

On Mar 20, 7:11=A0pm, Shayne <raz...@gmail.com> wrote:
> On Mar 19, 11:20=A0am, Tom Lavedas <tglba...@cox.net> wrote:
>
>
>
> > On Mar 19, 12:33 pm, Shayne <raz...@gmail.com> wrote:
>
> > > On Mar 19, 6:26 am, Tom Lavedas <tglba...@cox.net> wrote:
>
> > > > On Mar 19, 5:11 am, Shayne <raz...@gmail.com> wrote:
>
> > > > > I am trying to create a script that allows a user to start and sto=
p a
> > > > > service on a remote computer.
>
> > > > > I am having troubles with spaces in the command.
>
> > > > > Here is what I have so far.
> > > > > I am having troubles with line following Case "1" and Case "2"
>
> > > > > Any advice would be greatly appreciated.
>
> > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> > > > > Option Explicit
>
> > > > > Dim objmenu, username, wshshell, fso
> > > > > Set WshShell =3D WScript.CreateObject("WScript.Shell")
> > > > > Set fso =3D CreateObject("Scripting.FileSystemObject")
>
> > > > > Username =3D InputBox("Enter your admin username (domain\username)=
",
> > > > > "Enter Username")
> > > > > 'create an object from the gui_menu class
> > > > > Set objmenu =3D New gui_menu
> > > > > 'start the application
> > > > > objmenu.getInput
>
> > > > > Class gui_menu
> > > > > =A0 =A0 private Input, quit, strText, cmd, arrMenu, i, return, str=
Prog
>
> > > > > =A0 =A0 Private Sub pickInput
> > > > > =A0 =A0 =A0 =A0 'if you add anything to the menu array below, make=
sure you
> > > > > add a corresponding entry here
> > > > > =A0 =A0 =A0 =A0 Select Case Input
> > > > > =A0 =A0 =A0 =A0 =A0 =A0 Case "1"
>
> > > > '
> > > > ' I believe this is what you need ...
> > > > =A0 cmd =3D " ""sc \\remotecomputer stop ""Service with spaces in
> > > > name"""""
> > > > ' Escape the quotes around the service name and then around the
> > > > ' whole command as well.> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 startProg =
cmd
> > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 WScript.Sleep(22000)
> > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 getInput
> > > > > =A0 =A0 =A0 =A0 =A0 =A0 Case "2"
>
> > > > '
> > > > ' I believe this is what you need ...
> > > > =A0 cmd =3D " ""sc \\remotecomputer start ""Service with spaces in
> > > > name"""""
> > > > ' Watch for word wrap. =A0The statement between the comments is all =
one
> > > > ' line of code
> > > > '
>
> > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 startProg cmd
> > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 getInput
> > > > {snip}
> > > > > =A0 =A0 Private Sub startProg(cmd)
> > > > > =A0 =A0 =A0 =A0 =A0return =3D WshShell.Run("%windir%\system32\runa=
s.exe /user:" &
> > > > > username & cmd, 1, False)
> > > > > =A0 =A0 End Sub 'startProg
> > > > > End Class 'gui_menu
> > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> > > > See comment inline above ...
>
> > > > Tom Lavedas
> > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Dhttp://members.cox.net/tglbatch/wsh=
/-Hidequotedtext -
>
> > > > - Show quoted text -
>
> > > Thanks for the quick response.
>
> > > I would've thought that as well, but when I do that, the quotes are
> > > singling line termination or command termination.
> > > When I copy you command in, or put quotes between STOP and Service
> > > with Spaces
> > > I get
>
> > > Script: path to scritpt
> > > Line: 33
> > > Char 56
> > > Errror: Unterminated string constant
> > > Code: 800A0409
> > > Source: Microsoft VBScript compilation error
>
> > Ok, I just went and looked at the help for runas. =A0It uses a backslash=

> > as the escape character (JScript like). =A0The example was ...
>
> > =A0runas /env /user:u...@domain.microsoft.com "notepad \"my file.txt\""
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0note backslash^ =A0 =A0 =A0 =A0and ^
>
> > That means the string probably needs to be ...
>
> > =A0cmd =3D " ""sc \\remotecomputer start \"Service with spaces in name
> > \""""
>
> > I hope it doesn't also need to escape backslashes. =A0Another example
> > given suggests that it does NOT.
>
> > Also, AFAIK the user is still going to have to supply the proper
> > password - which might be problematic. =A0I don't use runas, but IIRC it=

> > does not accept redirection of the password and I don't remember the
> > WSHShell Run method's console window allowing user interaction. =A0I
> > don't *know* that is a problem (or have a solution to suggest), but
> > offer my tiny bit of information for what it's worth.
>
> > Tom Lavedas
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Dhttp://members.cox.net/tglbatch/wsh/
>
> Thanks,
> I tried that.
> Here are the variations which by the way did not work.
>
> cmd =3D " ""sc \\servername stop \"VMware NAT Service\""""
> cmd =3D " ""sc \\servername stop "VMware NAT Service""""
> cmd =3D " ""sc \\servername stop \VMware NAT Service\"""
>
> Don't mind the service name, it is the only service I have with
> spaces, to experiment on.
>
> As for the password, I am trying to keep it somewhat secure, in the
> sense of not having it prefilled in the file. But yet having a user
> know it unfortunately.

Ok I figured it out.
With your input, I continued looking into it.

It wasn't so much that the vbs was wrong as it was the command I was
issuing was not working at all.

Here what I was trying to issue.

runas /user:domain\user sc \\servername stop "service with spaces in
name"

That fails if typed and ran from a command line.

So working with what you provided me, and another collegues input.

I toyed with the command in the command prompt till it worked.

which is.
runas /user:domain\user "sc \\servername stop \"service with spaces in
name"\"

So with that in mind, I figured out the line I needed in my script.

cmd =3D " ""sc \\serername stop \""service with spaces in name""\"" "


Thanks again for all the input!

Shayne.

Re: Quoting within already quoted command by Bob

Bob
Thu Mar 20 21:54:01 CDT 2008

Shayne wrote:
> Thanks,
> I tried that.
> Here are the variations which by the way did not work.
>
> cmd = " ""sc \\servername stop \"VMware NAT Service\""""
> cmd = " ""sc \\servername stop "VMware NAT Service""""
> cmd = " ""sc \\servername stop \VMware NAT Service\"""
>
>

First, start with the result you are trying to achieve, i.e., the actual
text that you would type into the Run dialog (or into the command prompt
window). Test it to make sure it works. Then, copy that text into notepad or
some editor that allows search/replace functionality. Use that functionality
to replace all quotes with two quotes. Then copy the result of that
operation and paste it into the script:

cmd = "<result of search/replace operation>"

If that does not work for you show us:
1. the censored text that needs to be the result
2. the script statement you got as a result of my recommended procedure
3. the string that actually resulted from that script statement (echo it or
use fso to write it to a file)

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"