Skip to content

Instantly share code, notes, and snippets.

@Nilzor
Created March 7, 2012 11:47
Show Gist options
  • Save Nilzor/1992686 to your computer and use it in GitHub Desktop.
Save Nilzor/1992686 to your computer and use it in GitHub Desktop.
Saving all local users to a text file
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set listLocalUsers = objWMIService.ExecQuery("Select * from Win32_UserAccount Where LocalAccount = True")
dim Text
For Each localUser in listLocalUsers
Text = Text & "Short Name: " & localuser.Name
Text = Text & ", Full Name: " & localUser.FullName
Text = Text & ", Description: " & localUser.Description
Text = Text & chr(13)& chr(10)
Next
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set WriteStuff = myFSO.OpenTextFile("c:\temp\data.txt", 2, True)
WriteStuff.WriteLine(Text)
WriteStuff.Close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment