是否可以使用shell.run命令以管理员身份运行指定的程序?
例如:
shell.run(cmd.exe) <---Run this as admin
shell.run(Notepad) <---Run this as normal我知道我可以执行脚本以管理员身份运行,但这意味着脚本中的所有内容都是以管理员身份执行的。
我的另一个选择是分离脚本,以管理员身份运行一个脚本,并将需要以管理员身份运行的内容包含在该脚本中,然后调用另一个脚本来运行,并正常运行该脚本。
发布于 2012-10-25 09:20:28
Set oShell = CreateObject("Shell.Application")
oShell.ShellExecute "cmd.exe", , , "runas", 1
oShell.Run "nodepad.exe"(来源:http://social.technet.microsoft.com/Forums/eu/ITCG/thread/310e57f9-2367-4293-9f97-53d0e077aacc)
(更多信息:http://ss64.com/vb/shellexecute.html)
发布于 2012-10-25 09:13:57
Windows (至少从XP到Win7 )有一个runas命令,它可以执行您需要的操作。详情请参见here。
因此,您可以运行runas.exe,而不是运行cmd.exe,让cmd.exe作为要运行的程序。
发布于 2021-01-02 07:41:12
试试这个:
Dim ObjShell
Set ObjShell = CreateObject ("WScript.Shell")
ObjShell.Run "runas /K (command goes here) "
ObjShell.Run "notepad.exe"https://stackoverflow.com/questions/13060215
复制相似问题