James Posted March 11, 2009 Posted March 11, 2009 (edited) Little function I wrote. It changes the registry key for Windows Vista UAC. expandcollapse popup; #FUNCTION# ==================================================================================================== ================ ; Name...........: _Reg_UAC ; Description ...: Changes the UAC setting on or off ; Syntax.........: _Reg_UAC($ioSwitch = 1) ; Parameters ....: $ioSwitch - Turns on/off UAC, valid values: ; |0 - Off ; |1 - On ; Return values .: Success - 1 ; Failure: ; Not Vista 3 ; Off switch and registry match 1 ; On switch and registry match 2 ; Author ........: James Brooks (JamesBrooks) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; ==================================================================================================== =========================== Func _Reg_UAC($ioSwitch = 1) Local $strReg = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Policies\System" Local $strKey = "EnableLUA" If @OSVersion = "WIN_VISTA" Then ; Check if the key matches off If RegRead($strReg, $strKey) = 0 Then If $ioSwitch = 0 Then Return SetError(1); Error reg and switch are equal - off EndIf ElseIf RegRead($strReg, $strKey) = 1 Then If $ioSwitch = 1 Then Return SetError(2); Error reg and switch are equal - on EndIf Else RegWrite($strReg, $strKey, "REG_DWORD", $ioSwitch) Return 1; Good return EndIf Else Return SetError(3); Not Vista EndIf EndFunc ;==>_Reg_UAC Pretty bad but can be useful. I don't use SetError() much so it's probably wrong Edited January 30, 2010 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
TomV Posted April 27, 2009 Posted April 27, 2009 Thank you it works good [font="Comic Sans MS"][size="4"]My UDF's:[/size]1. _ChooseIconAnd this is just the beginning[/font]
Yashied Posted April 27, 2009 Posted April 27, 2009 (edited) What's wrong with System Configuration Utility (msconfig.exe)? I see no reason for the frequent use of activate/deactivate UAC. Moreover it will work only after reboot your system. Edited April 27, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Mat Posted April 27, 2009 Posted April 27, 2009 I think the only think wrong with it that I can see is that it returns 0 and ets Error to 1/2 when It's not changing the value. I would change it to this... If $ioSwitch = 1 Then Return SetError(2, 0, 1); Error reg and switch are equal - on EndIf or maybe: If $ioSwitch = 1 Then Return SetError(0, 2, 1); Error reg and switch are equal - on EndIf as then It won't set off alarm bells when the values are equal. Don't know if thats what you wan't, but it makes sense as if you tell it to set the key to 2, even if it doesn't do anything, if the key ends up 2 then it should be OK. Other than that, I think this should be run by anyone on vista... saves everyone some trouble. MDiesel AutoIt Project Listing
trancexx Posted April 27, 2009 Posted April 27, 2009 ...Other than that, I think this should be run by anyone on vista... saves everyone some trouble.MDieselI don't get it. How? ♡♡♡ . eMyvnE
James Posted December 27, 2009 Author Posted December 27, 2009 Old topic, but still worth noting. Apparently, this does not work on Windows 7, a different key? I haven't tested it, but thought it would be useful to note Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Lite Posted December 27, 2009 Posted December 27, 2009 Hello How can check, if UAC is Active ? like require the state of UAC. maybe can check, running service, registry, or dll call. Yashied you are right. the regkey: $strReg = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Policies\System" the settings are activ after reebot. regards lite
James Posted December 27, 2009 Author Posted December 27, 2009 Hello How can check, if UAC is Active ?like require the state of UAC. maybe can check, running service, registry, or dll call. Yashied you are right.the regkey: $strReg = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Policies\System"the settings are activ after reebot.regards liteIf I remember correctly, there is a key (I think GeoSoft noted this), that doesn't require a reboot. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
James Posted December 28, 2009 Author Posted December 28, 2009 (edited) If I remember correctly, there is a key (I think GeoSoft noted this), that doesn't require a reboot. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $strReg = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" $frmMain = GUICreate("UAC Control", 187, 50) $btnOn = GUICtrlCreateButton("Turn UAC On", 8, 8, 83, 33, 0) $btnOff = GUICtrlCreateButton("Turn UAC Off", 96, 8, 81, 33, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnOn _Reg_UAC() Case $btnOff _Reg_UAC(0) EndSwitch WEnd ; 1 = Default ; 0 = Off Func _Reg_UAC($ioSwitch = 1) Local $strKey = "ConsentPromptBehaviorAdmin" If @OSVersion = "WIN_VISTA" Then ; Check if the key matches off If RegRead($strReg, $strKey) = 0 Then If $ioSwitch = 0 Then Return SetError(0) ; Error reg and switch are equal - off EndIf ElseIf RegRead($strReg, $strKey) = 1 Then If $ioSwitch = 1 Then Return SetError(2) ; Error reg and switch are equal - on EndIf Else RegWrite($strReg, $strKey, "REG_DWORD", $ioSwitch) Return 1 ; Good return EndIf Else Return SetError(3) ; Not Vista EndIf EndFunc ;==>_Reg_UAC That should not require a reboot on Windows Vista. Edited December 28, 2009 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now