Hello,
Below function can be used to update user registry using HKU Registry hive without using ActiveSetup:
'User registry update function variables
Dim strRegPathSuffix,strRegValueName,strRegValuDec,strISString,strISDword
'Define Registry Hive Constants
Const HKU = &H80000003
'Function to update Registry for Computer users
Function UpdateUserReg(strRegPathSuffix,strRegValueName,strRegValuDec,strISString, strISDword)
Dim oReg,arrSubKeys,subkey,strKeyPath
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = ""
oReg.EnumKey HKU, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
'wscript.echo subkey
'Only set regsirty for existing users, hency excluding foloowing: .DEFAULT or S-1-5-18 or S-1-5-19 or S-1-5-20 or _Classes
If NOT ((InStr(1,subkey,".DEFAULT",1) > 0) OR (InStr(1,subkey,"S-1-5-18",1) > 0) OR (InStr(1,subkey,"S-1-5-19",1) > 0) OR (InStr(1,subkey,"S-1-5-20",1) > 0) OR (InStr(1,subkey,"_Classes",1) > 0)) Then
'Create desired registry key/value
strKeyPath = subkey & "\" & strRegPathSuffix
'wscript.echo strKeyPath
oReg.CreateKey HKU, strKeyPath
sWriteLog "Updating User Regsitry: " & "HKEY_Current_USERS\" & "\" & strRegPathSuffix & "\" & strRegValueName & "=" & strRegValuDec
' oReg.SetDWORDValue HKEY_USERS, strKeyPath, strRegValueName, strRegValuDec
If (strISString = 1) Then errorCode = oReg.SetStringValue(HKU, strKeyPath, strRegValueName, strRegValuDec)
If (strISDword = 1) Then errorCode = oReg.SetDWORDValue(HKU, strKeyPath, strRegValueName, strRegValuDec)
sWriteLog "Return Code: " & errorCode
End If
Next
End Function
'Calling Function
'Variable Definition for Function
'Call UpdateUserReg(strRegPathSuffix,strRegValueName,strRegValuDec,strISString, strISDword)
'If it has to be String strISString should be 1 else 0,
'Call UpdateUserReg("Software\Test\TestApplication\Settings","TestDWORD","122",0, 1)
'Similarly for DWORD strISDword should be 1 else 0
'Call UpdateUserReg("Software\Test\TestApplication\Settings","TestSTRING","TestValue",0, 1)
'The_D
Comments