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 = &H80000003 Dim binValue() strComputer = "." Set objReg=GetObject("winmgmts:\{impersonationLevel=impersonate\}!\\" _ & strComputer & "\root\default:StdRegProv") strKeyPath = "" objReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys strKeyPath = "\Control Panel\PowerCfg\GlobalPowerPolicy" strKeyPathUser = "\Software\Microsoft\Windows\CurrentVersion\Explorer" 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 if Next
1 comment
Hide comments