#include-once
#Region _UAC_SetLevel
; #FUNCTION# ;===============================================================================
;
; Name...........: _UAC_SetLevel
; Description ...: Sets the level of "User Account Control".
; Syntax.........: _UAC_SetLevel($iLevel)
; Parameters ....: $iLevel - The level to set UAC to.
; |0 = Never notify
; |1 = Notify on apps only (no dim)
; |2 = Notify on apps only
; |3 = Notify on apps and user
; Return values .: Success - Returns 1
; Failure - Returns 0
;
; Author ........: Djarlo Westmaas
; Modified.......:
; Remarks .......: Changes only take effect after a reboot.
; Related .......:
; Link ..........: <a href='http://www.autoitscript.com/forum/topic/139626-udf-useraccountcontol-setlevelau3/' class='bbc_url' title=''>http://www.autoitscript.com/forum/topic/139626-udf-useraccountcontol-setlevelau3/</a>
; Example .......; No
;
; ;==========================================================================================
Func _UAC
_SetLevel
($iLevel)
If $iLevel < 0 Or $iLevel > 3 Then Return SetError(1, 0, 0)
If @OSVersion <> "WIN_VISTA" And @OSVersion <> "WIN_7" Then Return SetError(2, 0, 0)
Local $sKey = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', $a[3], $aValue[3] = ['EnableLUA', 'ConsentPromptBehaviorAdmin', 'PromptOnSecureDesktop'], $iError = 0
If @OSArch = 'X64' And @AutoItX64 <> 1 Then $sKey = 'HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
If $iLevel = 0 Then Dim $a[3] = [0, 0, 0] ;Never notify
If $iLevel = 1 Then Dim $a[3] = [1, 5, 0] ;Notify on apps only (no dim)
If $iLevel = 2 Then Dim $a[3] = [1, 5, 1] ;Notify on apps only
If $iLevel = 3 Then Dim $a[3] = [1, 2, 1] ;Notify on apps and user
For $i = 0 To 2
$iError += RegWrite($sKey, $aValue[$i], 'REG_DWORD', $a[$i])
Next
If $iError <> 3 Then Return SetError(3, 0, 0)
Return 1
EndFunc ;==>_UAC_SetLevel
#EndRegion _UAC_SetLevel