Re: running vbscript syntax error
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 18:32:36 -0600
psang wrote:
"runas" does not support passing password as parameter, I found a
simple VBScript which will do the job. Here is the script but it keeps
saying syntax error.
Any help will be appreciated.
-----------------------------
dim wshShell
set wshShell=CreateObject("Wscript.Shell")
wshShell.Run("Runas /noprofile /user:ABCD\administrator "cscript
c:\Script\wmi-test.vbs"")
wshShell.AppActivate "Runas"
WScript.Sleep 100
wshShell.SendKeys "passwd~"
where abcd is a Machine Name
and wmi-test.vbs is a schedular job which has to run as administraor
I have no idea if this would work, but the syntax of the argument of the Run
method above is wrong. A string must be passed to the Run method. Any quotes
embedded in the string must be doubled. So, if the command is:
Runas /noprofile /user:ABCD\administrator "cscript c:\Script\wmi-test.vbs"
then the string would be (watch out for line wrapping, this is one line):
strCmd = "Runas /noprofile /user:ABCD\administrator ""cscript
c:\Script\wmi-test.vbs"""
The double quotes in the string are resolved to single quotes. So, I would
try:
wshShell.Run("Runas /noprofile /user:ABCD\administrator ""cscript
c:\Script\wmi-test.vbs""")
To troubleshoot, run a script where you define the value of strCmd as above,
then echo the value to the screen so you can see if it is correct. If there
is a syntax error, perhaps due to unbalanced quotes, you can fix it.
Wscript.Echo strCmd
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
.
- References:
- running vbscript syntax error
- From: psang
- running vbscript syntax error
- Prev by Date: Re: scripts
- Next by Date: How to send Alt+Numpad keys in AutoIt or VBScript
- Previous by thread: Re: running vbscript syntax error
- Next by thread: Re: scripts
- Index(es):
Relevant Pages
|