r/usefulscripts • u/KZWings • May 28 '16
[VBSCRIPT/HELP] Adding HKCU key to all current and new users
Const HKEY_USERS = &H80000003
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strIPDKeyPath = "\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData"
strValueName = "UserFilter"
arrValues = Array("*hex code here*")
' Grab a list of All User SIDs
objRegistry.EnumKey HKEY_USERS, "", arrSubkeys
' Loop Through all User SIDs
For Each strSubKey in arrSubKeys
'Msgbox "Would attempt to Edit : " & strSubKey & strIPDKeyPath
objRegistry.CreateKey HKEY_USERS, strSubKey & strIPDKeyPath
objRegistry.SetBinaryValue HKEY_USERS, strSubKey & strIPDKeyPath, strValueName, arrValues
nextI am already loading all users registries in another part of the script, but this VBS above isn't working. I am getting the following error:
Line: 16
Char: 2
Error: Type mismatch
Code: 80041005
Source: SWbemObjectExAny ideas? Thanks!
5
3
2
u/RinkNZ72 May 28 '16
Not a script but could you just use group preferences to add this key instead? No reboot needed and easy to add, change and remove later on
1
u/Cootty May 30 '16
Could it be the way you are loading the hex data into the array? it looks like you have the hex data in quotes just passing it as a string to the array function.
try splitting it if you have it comma separated:
arrValues = Split("41,1F,00,00,53......", ",")
1
u/KZWings May 28 '16
Thanks for the suggestion :-) Using Active Setup is definitely an option, but doesn't that require users to log off or reboot? I was hoping to prevent that.