I can use CreateObject("shell.application").ShellExecute
but can I run a cscript as administrator
? using that? I'm kind of a newbie vbscripter. Thanks!
Asked
Active
Viewed 2,131 times
0
2 Answers
0
Have you tried the RunAs
command? I posted a solution recently that walks you through getting the proper syntax for executing the RunAs
command from within VBScript.
Take a look and see if it helps.
0
The scriptPath is the path to your script you want to run as administrator
The Arguments is the commandline arguments you want to pass to the script. NOTE the Arguments are space separated, if you want to pass an argument that contains spaces you will need to enclose that arguments in quotes [Chr (34) is the quotes]. to do that you will need to write for example.
Arguments= chr (34) & "Hello World" & chr(34)
ScriptPath="Path to your script"
Arguments="Any arguments to pass to the script"
CreateObject("Shell.Application").ShellExecute "cscript.exe",_
Chr(34) & ScriptPath & Chr(34) & _
" " & Arguments, _
"", "runas", 1

Ronnie Matthews
- 473
- 4
- 13