[英]Running script on elevated cmd.exe
How do I ran a script after I open a command window using the below script? 使用以下脚本打开命令窗口后,如何运行脚本?
Set objSh = CreateObject("Shell.Application")
objSh.ShellExecute "cmd.exe", "uac" , "", "runas", 1
For example, how do I run ipconfig
as an admin using the above script? 例如,如何使用上述脚本以管理员身份运行
ipconfig
?
If you specify the /c
switch, then cmd.exe
will carry out the specified command and then terminate. 如果指定
/c
开关,则cmd.exe
将执行指定的命令,然后终止。
So, for example: 因此,例如:
Set objSh = CreateObject("Shell.Application")
objSh.ShellExecute "cmd.exe /c ipconfig", "uac" , "", "runas", 1
Alternatively, you could use the /k
switch, which works exactly the same way, except it keeps the command prompt on the screen once your command finishes executing. 另外,您可以使用
/k
开关,其工作方式完全相同,不同之处在于,一旦您的命令执行完毕,它将在屏幕上保留命令提示符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.