List all users on a computer and output to local directory
Posted on 2013-01-26
I am trying to create a script that will list all users on a computer and then save that file as the computer name to a specified directory. Not knowing much about vbscript, I have googled and come up with the script below that will somewhat work. The issue with this script is that it displays a box on the screen for each user account.
I would like to modify this script so that is will save the output to C:\kworking and name the file the same as the computer name. I've tried but with my little scripting experience I'm getting nowhere fast. I'm sure an expert can modify this in a few seconds.
Thanks for any input!
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