0

使用以下脚本打开命令窗口后如何运行脚本?

Set objSh = CreateObject("Shell.Application")
objSh.ShellExecute "cmd.exe", "uac" , "", "runas", 1

例如,如何ipconfig使用上述脚本以管理员身份运行?

4

1 回答 1

0

如果指定了/c开关,那么cmd.exe将执行指定的命令然后终止。

因此,例如:

Set objSh = CreateObject("Shell.Application")
objSh.ShellExecute "cmd.exe /c ipconfig", "uac" , "", "runas", 1

或者,您可以使用/k开关,它的工作方式完全相同,只是在命令执行完成后它会在屏幕上保留命令提示符。

于 2012-01-31T06:03:55.817 回答