平台和设置:
AutoHotkey_L Unicode x86 1.1.13.0
RegView=Default
64位操作系统(W7)
32位脚本
嗨,各位,
下面的代码行返回ErrorLevel=1:
SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System,PromptOnSecureDesktop,0
当我手动修改注册表时,它可以正常工作。顺便说一句,RegWrite在ANSI x86二进制文件中以同样的方式失败(我还没有尝试使用Unicode x64二进制文件)。有人知道为什么RegWrite失败了吗?谢谢你,乔
发布于 2013-10-02 07:47:51
对注册表项的操作通常假定管理员权限,在未关闭UAC的情况下,必须以明确的方式获得这些权限,直到WIN或更高版本。
对于AHK,请调用以下函数(来源):
RunAsAdmin() {
Loop, %0% ; For each parameter:
{
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
params .= A_Space . param
}
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
If A_IsCompiled
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
Else
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
ExitApp
}
}https://stackoverflow.com/questions/19084383
复制相似问题