From: wndr on
Thank you so much to all of you. It works.
"Al Dunbar" <alandrub(a)hotmail.com> wrote in message
news:FFFF56E9-04C0-489B-A329-E91D7FA51521(a)microsoft.com...
>
>
> "\Rems" <Rems(a)discussions.microsoft.com> wrote in message
> news:11B07707-2329-4EAF-A926-676FC783BBFC(a)microsoft.com...
>> "Al Dunbar" wrote:
>>
>>>
>>>
>>> "Pegasus [MVP]" <news(a)microsoft.com> wrote in message
>>> news:O62A3gjlKHA.5608(a)TK2MSFTNGP05.phx.gbl...
>>> >
>>> >
>>> > "wndr" <wndr(a)hotmail.com> said this in news item
>>> > news:eWvt2LjlKHA.1652(a)TK2MSFTNGP05.phx.gbl...
>>> >> Hi All. I am having a problem with syntaxis in this line:
>>> >> Call WSHShell.Run("sc config uctsecmgr obj= " & sAccount & "
>>> >> password= "
>>> >> & sPassword)
>>> >> Please help. Di I put some extra "" or space, or maybe I need to
>>> >> provide
>>> >> a path to sc.
>>> >> Please help.
>>> >
>>> > What is the problem you experience? If you don't know then you should
>>> > use
>>> > the Exec rather than the Run method so that you can capture the output
>>> > of
>>> > sc.exe.
>>>
>>> SC.exe should normally be available on the path, but I would recommend
>>> specifying at least the file type (i.e. SC.exe instead of just SC). If
>>> the
>>> default folder contained a file named sc.bat or sc.cmd, for example,
>>> that
>>> would be run instead of the intended executable.
>>>
>>> In your particular case, it could also be that the variables sAccount
>>> and/or
>>> sPassword might be either incorrectly spelt or contain values other than
>>> what you expect.
>>>
>>> It may be helpful to assemble the command to be .run into a variable and
>>> display it first to make sure it is what you intended, i.e.:
>>>
>>> cmd2run = "sc config uctsecmgr obj= " & sAccount & " password= "
>>> &
>>> sPassword
>>> wscript.echo "cmd2run:" & cmd2run
>>> WSHShell.Run cmd2run
>>>
>>> In fact, I almost always code that way from the start, as it helps avoid
>>> many annoying errors.
>>>
>>> /Al
>>>
>>
>>
>> There could also be a problem with one or more characters used in the
>> variables sAccount and/or sPassword when actually running the command
>> line.
>> Therefore instead of :
>> wscript.echo "cmd2run:" & cmd2run
>> use:
>> Call WSHShell.Run("cmd /c echo cmd2run: " & cmd2run & " & pause")
>> for checking the values.
>
> Excellent point, thanks for pointing it out...
>
> /Al
>
>> Some characters need to be
>> escaped!(http://www.robvanderwoude.com/escapechars.php)
>> OR.. in this case even better would be to wrap the values between quotes
>> on
>> the command line:
>>
>> ' assemble the command
>> cmd2run = "sc.exe config uctsecmgr"
>> cmd2run = cmd2run & " obj=""" & sAccount & """"
>> cmd2run = cmd2run & " password=""" & sPassword & """"
>>
>> Call WSHShell.Run("cmd /c " & cmd2run, , true)
>>
>>
>> \Rems
>