在提升的 cmd.exe 上运行脚本

发布于 2025-01-01 05:51:49 字数 203 浏览 8 评论 0原文

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

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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜还是长夜 2025-01-08 05:51:49

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

因此,例如:

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

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

If you specify the /c switch, then cmd.exe will carry out the specified command and then terminate.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文