1

I have a Windows Batch script and I want it to ask for administrator privileges before executing the commands inside it. How can I do that?

4

1 回答 1

0

两种选择:

  1. 从 WSH 脚本引发提升,如博客文章Scripting Elevation on Vista中所述。

  2. 使用引发 UAC 提示的外部可执行文件,例如Elevate32.exe/Elevate64.exe

对于您的方案,#2 可能更可取,因为您可以检测提升提示是否已取消(退出代码 1223),并且您还可以等待启动的可执行文件完成后再继续(-w 参数)。

账单

于 2013-06-03T15:57:25.220 回答