Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runas in WshShell to execute command with multiple switches 1

Status
Not open for further replies.

sxie

Technical User
Sep 10, 2003
8
US
I am very new to scripting. My challenge here is to write a script, which I will apply via Group Policy later, to use runas to execute a command with multiple switches. Below are the lines I am troubleshooting:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "runas /user:domain\useracct secedit /configure /db c:\abc.sdb /cfg c:\abc.inf"

The problem I am having is that runas will not take the switches after the command "secedit".

Could someone help?!!!
 
Don't know about runas but here is a script I use to run a cobol program with 3 sets of arguments and a pkzip backup
with 2 arguments (switches) being the zip file name and the file to be zipped. Hope this helps.
Enjoy Bob

Set ss = CreateObject("WScript.Shell")
ss.run "C:RUNCOBOL.EXE C:\COBOLTEST\RSUPDATE K L=c:\rmcobol\RMBARS.DLL L=c:\rmcobol\C$BITMAP.DLL ",1,true
set ss = nothing



returncode=msgbox ("mount a 3.5 diskette for backup",65,"backup start")
if returncode=1 then
Set ss = CreateObject("WScript.Shell")
ss.run "COMMAND /C C:\util\pkzip.exe a:master77.zip y:\rds\rds77\master.txt ",1,TRUE
set ss = nothing
msgbox "backup is done please remove the diskette",64,"backup finished"
end if
 
There is a vb script that will allow you to use the runas on any program. you just pass it the parameters. I think I found it here not sure I can have a look for it if you need!
 
You can also use the program "psexec.exe" from This will allow you to run apllications on a remote machine, passing credentials and running applications WITH switches.

You can run psexec.exe from the WshShell.Run just like any other command line app.

Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "psexec \\computername -u username -p password command /switch"

-= j@ckle =-
 
does it help if you enclose your sting/command with quotes?
ie
WshShell.Run Chr(34) & "blaa.exe kfkf -t -k" & Chr(34)
regards
von moyla
 
I've used the run command with multiple switches before by placing the command into a variable.

runlit = "runas /user:domain\useracct _
secedit /configure /db c:\abc.sdb /cfg c:\abc.inf"
runchk = wshshell.run(runlit),1,true


This might work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top