Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个脚本,我需要以管理员身份运行,就像我右键单击 cmd.exe 并单击Run As Administrator 一样。
目前这就是我所拥有的:
Call WSHShell.Run("cmd.exe /K netdom renamecomputer ... end code")
您是否尝试过使用 ShellExecute?
RunCmdElevated.vbs
Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "cmd.exe", "/k echo test", "", "runas", 1
wscript RunCmdElevated.vbs
给
测试 C:\Windows\system32>
测试
C:\Windows\system32>
在新窗口中。“1”是查看模式
http://ss64.com/vb/shellexecute.html