Script a registry change for all users

Update: This doesn't really work.  It seems to only work on all LOADED user hives, usually this won't work for non-logged in users.

 

This page provides an example script to change a particular registry value for each user on the local computer.

http://www.windowsitpro.com/Article/ArticleID/48128/48128.html?Ad=1

I'll paste the sample here, but it will likely be damaged by this form's security filters:
 

const HKEY_USERS = &H80000003
Dim binValue()
strComputer = "."

Set objReg=GetObject("winmgmts:!\\" _
   & 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









tags: wscript, vbscript, registry, windows, winxp, win2k, enumerate, hkcu, hk_users

Related Scribbles:
  • Windows Scripting Host (WSH) Notes
  • WMI Overview
  • cscript.exe and wscript.exe notes
  • Registry Tools


  • ID: 827
    Author:
    leonard
    Date Updated:
    2009-12-30 15:20:25
    Date Created:
    2007-03-07 14:23:11

    Edit

    Comments?
     >> Leonard Chan's Homepage  >> Scribble Web  >> Script a registry change for all users
    leonard.lotus-land.ca is hosted by Perceptus Solutions Inc.