Code: Select all
ValueType := "REG_DWORD"
KeyName := "HKLM\SOFTWARE\Policies\Google\Chrome"
ValueName := "IncognitoModeAvailability"
Run, % "AutoHotkeyU32.exe RegWrite.ahk " ValueType " " KeyName " " ValueName " " 0
; RegWrite.ahk
Loop, %0%
params .= A_Space %A_Index%
params := SubStr(params, 2)
; https://autohotkey.com/docs/Run#RunAs
full_command_line := DllCall("GetCommandLine", "str")
if !(A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) {
try {
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" "%params%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%" "%params%"
}
ExitApp
}
RegWrite, % A_Args[1], % A_Args[2], % A_Args[3], % A_Args[4]
if ErrorLevel
MsgBox, % A_LastError "`n`n" """" params """"
else
MsgBox, % "No error"