Write to HKCU issue

Hi,
Need some advice on writing to HKCU when multiple users are logged-on. We have currently vbscript to update trusted sites, and I’m looking at converting this to Action Script. The script works fine in 90% of our cases however I’m running into issue when I target devices where multiple users are logged-in, I’m trying to find a way to update these user hives in such scenario.

Fixlet (Small snippet)

createfile until @end_create_reg_file
Windows Registry Editor Version 5.00

[{current user keys (logged on users) of registry}\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\abc.com]
“http”=dword:2
“https”=dword:2
“*”=-
@end_create_reg_file

move __createfile update.reg
waithidden regedit /s “update.reg”

we also have corresponding relevance to check for this and re-apply if neccessary

(not exists value “http” whose (it as integer = 2) of keys “SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\abc.com” of current user keys (logged on users) of native registry) Or (not exists value “https” whose (it as integer = 2) of keys “SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\abc.com” of current user keys (logged on users) of native registry)

If I’m not using the plural version then I get error message when multiple users are logged-in.

I’m looking for easy way (if possible wtih Action Script) to update keys when multiple users are logged-in. With our VBScript we basically iterate over the user hives and update each hive accordingly, have not found a way to do this using Action Script. I could possible explore the option using PowerShell but then still need to find a way for the relevance to become false in scenario with multiple users

any suggestions/ideas are welcome

Thx!

You could use LGPO.EXE to apply the settings as a Local Group Policy so that it applies to both current and future user logins; or you’d need to have the ActionScript generate & run a vbscript or batch or powershell to loop through the users.

There’s no loop construct in ActionScript itself but you could certainly call and external script with that logic. You might loop through each entry in HKEY_USERS\ hive.

An approach I’ve used for managing keys that are user profile centric is to have detection based on the existence of the key under keys of the HKU hive then as the action, capture all the HKU keys as a parameter then pass that to a “for” loop in CMD to perform the desires activity.

Eg

Detection
(windows of operating system) and (exists keys "SOFTWARE\Microsoft\Exchange\Exchange Provider" whose (exists value "Closest GC" of it) of keys of key "HKU" of registry)

Action

parameter "keys" = "{"%22" & (concatenation "%22,%22" of (pathnames of keys "SOFTWARE\Microsoft\Exchange\Exchange Provider" whose (exists value "Closest GC" of it) of keys of key "HKU" of registry)) & "%22"}"

waithidden cmd.exe /c "for %a in ({parameter "keys"}) do (reg delete %a /v "Closest GC" /f)"
1 Like