All props to the original poster. However I have edited the script to not be dependent on WMI. This is crucial in dealing with thin clients as WMI is often not baked into the OS image.
I was in a hurry so it is a bit dirty, however it works. Please feel free to clean up / repost.
Sub SetAllUsersRegKey(sKeyName,sData,sType)
'Example: SetAllUsersRegKey "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1A00",0000000,"REG_DWORD" Dim oShell, sCommand, oUserRegDic, oSubFolder, sKey, oReg, sSubKey, aRegKeys(), iKeys, aDesktopKeys, oFSO, oExec, oStdOut, sLine, iErrorLevel
iKeys = 0
Set oShell = CreateObject("Wscript.Shell")
sCommand = "%comspec% /c " & oShell.ExpandEnvironmentStrings("%WINDIR%") & "\System32\Reg.exe "
oShell.RegWrite "HKCU\" & sKeyName,sData,sType
Set oUserRegDic = CreateObject("Scripting.Dictionary")
Set oFSO = CreateObject("Scripting.FileSystemObject")
For Each oSubFolder In oFSO.GetFolder(Left(oShell.SpecialFolders(0),InStr(oShell.SpecialFolders(0),"\All ")-1)).Subfolders
'Look into the users special folder and get a list of all subfolders (existing users)
On Error Resume Next '"disable" error handeling
oUserRegDic.Add oSubFolder,oSubFolder.Name
On Error GoTo 0 ' "enable" error handeling
Next For Each sKey In oUserRegDic.Keys 'Slam all user regdata into HKU for editing later
oShell.Run sCommand & "LOAD " & Chr(34) & "HKU\" & oUserRegDic.Item(sKey) & Chr(34) & " " & chr(34) & sKey & "\NTUser.dat" & Chr(34),0,True
Next Set oExec = oShell.Exec("reg query HKU") Do While oExec.Status = 0 'holds the script until comand has finished.
WScript.Sleep 100
Loop Set oStdOut = oExec.StdOut Do Until oStdOut.AtEndOfStream 'Populates aRegKeys with all sub keys in HKU
sLine = Trim(oStdOut.ReadLine)
If Len(sLine) > 1 Then 'Thows out empty line
Select Case sLine
Case "! REG.EXE VERSION 3.0" 'do nothing / remove uneeded data
Case "HKEY_USERS" 'do nothing / remove uneeded data
Case Else
If Not oStdOut.AtEndOfStream then 'prevents extra array element
ReDim Preserve aRegKeys(iKeys + 1)
end if
aRegKeys(iKeys) = sLine
iKeys = iKeys + 1
End Select
End If
Loop For Each sSubkey In aRegKeys
Set oExec = oShell.Exec("reg query " & Chr(34) & sSubkey & "\Control Panel\Desktop" & Chr(34))
Do While oExec.Status = 0 'holds the script until comand has finished.
WScript.Sleep 100
Loop iErrorLevel = oExec.ExitCode If iErrorLevel = 0 then' if the reg query is sucsessful the key belongs to a user
oShell.RegWrite sSubkey & "\" & sKeyName,sData,sType 'do the reg edit
End if
Next For Each sKey In oUserRegDic.Keys 'Clean up user regdata entered earlier
oShell.Run sCommand & "UNLOAD " & Chr(34) & "HKU\" & oUserRegDic.Item(sKey) & Chr(34),0,True
Next End Sub