Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
October 16, 2005
A. To update all users at once, you need to update values via the HKEY_USERS key. The following code, which you can download here enumerates through all the users under HKEY_USERS and sets part of a binary value (in this example, the setting to control the "perform no action when a laptop lid is shut" under Power Settings). You can change the code in the example to perform whatever actions you want.
const HKEY_USERS = &H80000003Dim binValue()strComputer = "."Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" _ & strComputer & "rootdefault:StdRegProv")strKeyPath = ""objReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeysstrKeyPath = "Control PanelPowerCfgGlobalPowerPolicy"strKeyPathUser = "SoftwareMicrosoftWindowsCurrentVersionExplorer"For Each subkey In arrSubKeys if objReg.GetBinaryValue(HKEY_USERS, subkey & strKeyPath, "Policies", binValue) = 0 then objReg.GetStringValue HKEY_USERS, subkey & strKeyPathUser, "Logon User Name", userName Wscript.Echo "Updating SID - " & subkey & ", Username - " & userName binValue(51)=128 objReg.SetBinaryValue HKEY_USERS, subkey & strKeyPath, "Policies", binValue end ifNext
You May Also Like