WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

User Profiles

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Get a List of All User Profiles

Keywords:     user profiles

Question:

I would like to do a regqueryitem to get me a list of all users that where on the machine.

Answer:

Win95 answer:

The root of @REGUSERS contains keys only for .Default, and, if you have individual logins selected, the current user logged in.

What you want to do is do a:

	List = RegQueryKeys (@REGMACHINE,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList")
which will give you a list of all the profiles created on that computer. Of course, anyone who clicks on "Cancel" on the Windows Login dialogue will get .Default, and you cannot determine who they are, or whether someone with a profile clicked "Cancel".

One way around it IF they connect to another network is to perhaps get their login name on that network and store it someplace, into a list, and hence gain over time a list of all users.


WIN95: USER.DAT and Profiles

Question:

Is there a way to stuff user specific registry values to a USER.DAT that is currently not loaded in memory? When profiles are enabled in Win95, each user has their own USER.DAT. Therefore, I would like to run a winbatch which populates a value under the HKEY_Current_User for all user.dat files which exist on the machine without having to login as each of the users.

REGEDIT has nice command line feature (only when in MS-DOS mode, and not in a DOS window) that allows you to put registry values into a specific USER.DAT or MACHINE.DAT -- ex.) "regedit /R:c:\windows\user.dat c:\temp\test.reg." Unfortunately, this creates a .DEFAULT key for all other USER.DATs aside from the C:\WINDOWS\USER.DAT. For example, inserting a key called "TEST" under the HKEY_Current_USER for c:\windows\profiles\test1234\user.dat produces a HKey_Current_User\.DEFAULT\TEST for that user.

Is there any way to do this with Winbatch?

Answer:

I've used RegLoadHive to write a subroutine for changing a registry key for all users, including all defined profiles and the DEFAULT user (whose profile is used when no one is logged on).

I do a RegQueryKeys on HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList (for NT, change "Windows" to "Windows NT"), then loop through and ItemExtract each profile.

For each subkey, the value named ProfileImagePath tells where to find the USER.DAT file (or NTUSER.DAT for Windows NT). RegExistKey tells if the profile is active (exists under HKEY_USERS), in which case I don't need to load it. Otherwise, I load it, naming it whatever the subkey was in ProfileList (for NT, this will be the SID#; otherwise, it's usually the user name).

Then I do whatever changes are called for, and unload the hive only if I had to load it. The changes have to be made in HKEY_USERS (not HKEY_CURRENT_USER) because the hive may not be the current user. If the Default User (used for Guest accounts in NT) needs to be changed, it needs to be loaded explicitly since it won't be in ProfileList. The System Default User (used by NT while at the Ctrl-Alt-Del logon prompt) is already loaded as HKEY_USERS\.DEFAULT, so if I need to change it I don't need to load it. Working on a script right now using this techniqute to change the Shell Folders and User Shell Folders directories for all users (folders that hold the Desktop, Start Menu and other shortcuts, and application data for each user profile).


Article ID:   W13158
Filename:   Get List of User Profiles and Update Registry with User.Dats.txt
File Created: 2001:02:22:15:46:08
Last Updated: 2001:02:22:15:46:08