Users registry query

(imported topic written by mcalvi91)

We are trying to find a way to retrieve the default printer from a system for every user on the system. I can do the following for the HKCU hive but want all the users and not just the current user listed.

q: value “device” of key “Software\Microsoft\Windows NT\CurrentVersion\Windows” of key “HKEY_CURRENT_USER” of registry

A: hp LaserJet 1320 PCL 6,winspool,Ne01:

T: 0.413 ms

I: singular registry key value

Is there a way to iterate the all users hives to get the info so we can put it into a text file for an upcoming migration?

(imported comment written by BenKus)

You can iterate across the keys in HKEY_USER… Try this (I excluded a couple of the built-in accounts):

values “device” of keys “Software\Microsoft\Windows NT\CurrentVersion\Windows” of keys whose (name of it as lowercase != “.default” AND name of it != “S-1-5-19” AND name of it != “S-1-5-20”) of key “HKEY_USERS” of registry

The only question I am not sure about is if the registry hives weren’t loaded…

Ben