Make Changes to All Profiles - VB Script

Make Changes to All Profiles - VB Script
MtBiker's picture

This is a simple VB script to modify all the profiles at once. Most the time you can use the "All Users" profile to make changes to all the profiles but there has been times when I've found this little script handy. For instance, it's a nice way of printing out all profiles on a system. But there are many things that this script can do.

'This script will allow you to make changes to all current profiles in the system

' strValue = user profiles (C:\Documents and Settings\profile)

On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
 
Set objRegistry=GetObject("winmgmts:\\" & _ 
  strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
 
For Each objSubkey In arrSubkeys
  strValueName = "ProfileImagePath"
  strSubPath = strKeyPath & "\" & objSubkey
  objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
  'replace this line with the tasks you wish to accomplish with the profiles. Use the strValue varible
  Wscript.Echo strValue
Next

As you will notice, there is a place in the for loop of the script to add the action item you would like taken place. Play with it, hope somebody else finds something useful for this.

If you have questions, you can reach me on the Altiris Juice Chat, my nick is MtBiker

3.208335
Average: 3.2 (24 votes)

Good Start for profile enumeration

JoeVan's picture

This is a good start to generate a list of profile GUIDs (which I've needed in the past) and profile locations. A little more work is needed if you want to modify settings within those profiles. You'd want to mount the ntuser.dat located in the paths you find and then modify desired settings within those temporary hive mountpoints.