Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用另一个vbscript以管理员身份运行cscript?_Vbscript_Shellexecute_Wsh_Createobject - Fatal编程技术网

如何使用另一个vbscript以管理员身份运行cscript?

如何使用另一个vbscript以管理员身份运行cscript?,vbscript,shellexecute,wsh,createobject,Vbscript,Shellexecute,Wsh,Createobject,我可以使用CreateObjectshell.application.ShellExecute,但我可以作为管理员运行cscript吗?用那个?我有点像个新手。谢谢 您是否尝试过RunAs命令?我最近发布了一个解决方案,该解决方案指导您从VBScript中获取执行RunAs命令的正确语法 并查看是否有帮助。脚本路径是您希望以管理员身份运行的脚本的路径 参数是要传递给脚本的命令行参数。请注意,参数是以空格分隔的,如果要传递包含空格的参数,需要将该参数括在引号中[Chr 34是引号]。要做到这一点,

我可以使用CreateObjectshell.application.ShellExecute,但我可以作为管理员运行cscript吗?用那个?我有点像个新手。谢谢

您是否尝试过RunAs命令?我最近发布了一个解决方案,该解决方案指导您从VBScript中获取执行RunAs命令的正确语法


并查看是否有帮助。

脚本路径是您希望以管理员身份运行的脚本的路径

参数是要传递给脚本的命令行参数。请注意,参数是以空格分隔的,如果要传递包含空格的参数,需要将该参数括在引号中[Chr 34是引号]。要做到这一点,你需要写的例子。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