The WMI ProviderArchitecture method does not appear to be needed. You can update HKLM and HKEY_USERS 32 bit and 64 bit entries directly and you can do the same with the not logged on users by loading the NTUser.dat and UsrClass.dat files. HKCU does not need to be edited directly, as it's covered by updating HKEY_USERS. Here's the code (run as administrator):
Const HKLM = &H80000002
Const HKU = &H80000003
Set oWSH = CreateObject("WScript.Shell")
Set oReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
Dim Prefix, SoftwareClasses
UpdateUserTemplate = True
UpdateHKLM
If UpdateUserTemplate Then
Prefix = "HKEY_LOCAL_MACHINE\TempHive"
ProfilePath = "C:\Users\Default"
oWSH.Run "reg load HKLM\TempHive " & chr(34) & ProfilePath & "\AppData\Local\Microsoft\Windows\UsrClass.dat" & chr(34), 0, True
SoftwareClasses = ""
UpdateUserClasses
oWSH.Run "reg unload HKLM\TempHive", 0, True
oWSH.Run "reg load HKLM\TempHive " & chr(34) & ProfilePath & "\NTUser.dat" & chr(34), 0, True
UpdateUserOther
oWSH.Run "reg unload HKLM\TempHive", 0, True
End If
Key = "Software\Microsoft\Windows NT\CurrentVersion\ProfileList"
Result = oReg.EnumKey(HKLM, Key, ArrProfileList)
If Result=0 Then
For Each SID In ArrProfileList
If Len(SID)=45 Then
Result = oReg.EnumKey(HKU, SID, ArrHKU)
If Result=0 Then
UpdateUser True,SID 'Logged on user
Else
UpdateUser False,SID 'Not logged on user
End If
End If
Next
End If
Sub UpdateUser(LoggedOn,SID)
If LoggedOn Then
Prefix = "HKEY_USERS\" & SID
SoftwareClasses = "\Software\Classes"
End If
If Not LoggedOn Then
Prefix = "HKEY_LOCAL_MACHINE\TempHive"
ProfilePath = oWSH.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\" & SID & "\ProfileImagePath")
oWSH.Run "reg load HKLM\TempHive " & chr(34) & ProfilePath & "\AppData\Local\Microsoft\Windows\UsrClass.dat" & chr(34), 0, True
SoftwareClasses = ""
End If
UpdateUserClasses
If Not LoggedOn Then
oWSH.Run "reg unload HKLM\TempHive", 0, True
oWSH.Run "reg load HKLM\TempHive " & chr(34) & ProfilePath & "\NTUser.dat" & chr(34), 0, True
End If
UpdateUserOther
If Not LoggedOn Then oWSH.Run "reg unload HKLM\TempHive", 0, True
End Sub
'HKLM registry entries go here:
Sub UpdateHKLM
oWSH.RegWrite "HKLM\Software\_Test\StrTest", "Test", "REG_SZ"
oWSH.RegWrite "HKLM\Software\_Test\DWTest", "1", "REG_DWORD"
oWSH.RegWrite "HKLM\Software\WOW6432Node\_Test\StrTest", "Test", "REG_SZ"
oWSH.RegWrite "HKLM\Software\WOW6432Node\_Test\DWTest", "1", "REG_DWORD"
End Sub
'User registry entries that are in the Classes subkey go here:
Sub UpdateUserClasses
oWSH.RegWrite Prefix & SoftwareClasses & "\CLSID\_Test\StrTest", "Test", "REG_SZ"
oWSH.RegWrite Prefix & SoftwareClasses & "\CLSID\_Test\DWTest", "1", "REG_DWORD"
oWSH.RegWrite Prefix & SoftwareClasses & "\WOW6432Node\CLSID\_Test\StrTest", "Test", "REG_SZ"
oWSH.RegWrite Prefix & SoftwareClasses & "\WOW6432Node\CLSID\_Test\DWTest", "1", "REG_DWORD"
End Sub
'User registry entries that are NOT in the Classes subkey go here:
Sub UpdateUserOther
oWSH.RegWrite Prefix & "\Software\_Test\StrTest", "Test", "REG_SZ"
oWSH.RegWrite Prefix & "\Software\_Test\DWTest", "1", "REG_DWORD"
End Sub