我将其编译为可执行文件,但要打开它,我必须右键单击并按“以管理员身份运行”。我希望它每次运行时都请求管理员权限,但该怎么做呢?
我不能这样做:
因为当我将其复制到第二台计算机时它不起作用。
尝试将其添加到自动执行部分(脚本顶部):
; If the script is not elevated, relaunch as administrator and kill current instance:
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try ; leads to having the script re-launching itself as administrator
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
并重新编译脚本。
欲了解更多详情,请阅读https://autohotkey.com/docs/commands/Run.htm#RunAs https://autohotkey.com/docs/commands/Run.htm#RunAs.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)