Hello,
I found this script: http://www.autoitscript.com/forum/topic/103218-advanced-enable-disable-uac-by-alienstar/
I tried to use the modded code by Smashly, but it would not run correctly. I have changed the code sligthly from the original and it seems to function properly and I see, in the User Account Control settings, the slider reflects the setting it should be.
I just want to throw this out there to see if I am missing anything important with the code. Thanks!
I found this script: http://www.autoitscript.com/forum/topic/103218-advanced-enable-disable-uac-by-alienstar/
I tried to use the modded code by Smashly, but it would not run correctly. I have changed the code sligthly from the original and it seems to function properly and I see, in the User Account Control settings, the slider reflects the setting it should be.
I just want to throw this out there to see if I am missing anything important with the code. Thanks!
[ autoit ]
#RequireAdmin #RequireAdmin #include "Constants.au3" global $iPreviousValue $iPreviousValue = _Toggle_UAC() msgbox(0,"$iPreviousValue",$iPreviousValue) sleep(7000) msgbox(0,"","Sleep Over") $iPreviousValue = _Toggle_UAC() ; #FUNCTION# ==================================================================================================================== ; Name...........: _Toggle_UAC ; Description ...: Toggle or Force UAC Off or On or Query UAC current setting without changing. ; Syntax.........: _Toggle_UAC([$iValue = -2]) ; Parameters ....: $iValue - [Optional] Default is -2, see below for explanations and other values. ; -1 = Toggle the current UAC to the oposite of what it is currently. ; If UAC is curently disabled then It will be enabled using 1, ; Prompt the Consent Admin to enter his or her user name and password ; (or another valid admin) when an operation requires elevation of privilege. ; -2 = Toggle the current UAC to the oposite of what it is currently. ; If UAC is curently disabled then It will be enabled using 2, ; Admin Approval Mode to select either "Permit" or "Deny" an operation that requires elevation of privilege. ; -3 = Return the current UAC value found in the registry, don't change anything. ; 0 = Set UAC to 0 Allow the Consent Admin to perform an operation that requires elevation without consent or credentials. ; 1 = Set UAC to 1 Prompt the Consent Admin to enter his or her user name and password ; (or another valid admin) when an operation requires elevation of privilege. ; 2 = Set UAC to 2 Admin Approval Mode to select either "Permit" or "Deny" an operation that requires elevation of privilege. ; Return values .: Success - Value that was found in the registry before changinging and @error 0, Return could be as follows: ; 0 = UAC was disabled ; 1 = UAC was Prompt the Consent Admin to enter his or her user name and password ; 2 = UAC was Admin Approval Mode to select either "Permit" or "Deny" ; Failure - -1 and @error ; @error 1 = Current user is not Admin ; @error 2 = OS is not Vista or Win 7 ; @error 3 = Reading the the registry key failed, check @extended for the returned error from RegRead() as to why it failed. ; @error 4 = Writing the registry keyname value failed, check @extended for the returned error from RegWrite() as to why it failed. ; @error 5 = $iValue parameter not valid ; Author ........: AlienStar ; Modified.......: smashly ; Remarks .......: ; Related .......: ; Link ..........: http://msdn.microsoft.com/en-us/library/cc232761%28v=prot.10%29.aspx ; Example .......: ; =============================================================================================================================== Func _Toggle_UAC($iValue = -2) If Not IsAdmin() Then Return SetError(1, 0, -1) If Not StringInStr("WIN_VISTA|WIN_7", @OSVersion) Then Return SetError(2, 0, -1) Local $sHKLM, $sName, $iReadValue, $iNewValue $sHKLM = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" $sName = "ConsentPromptBehaviorAdmin" $iReadValue = RegRead($sHKLM, $sName) ;msgbox(0,"$iReadValue",$iReadValue) ;If @error Then Return SetError(3, @error, -1) ;msgbox(0,"@extended",@extended) Switch $iValue Case -1, -2 Switch $iReadValue Case 0 ;$iNewValue = Abs($iValue) $iNewValue = $iPreviousValue ;msgbox(0,"$iNewValue",$iNewValue) Case Else $iNewValue = 0 ;msgbox(0,"$iNewValue",$iNewValue) EndSwitch Case -3 Return SetError(0, 0, $iReadValue) Case 0, 1, 2 $iNewValue = $iValue Case Else Return SetError(5, 0, -1) EndSwitch RegWrite($sHKLM, $sName, "REG_DWORD", $iNewValue) If @error Then Return SetError(4, @error, -1) Return SetError(0, 0, $iReadValue) EndFunc ;==>_Toggle_UAC