Created
March 7, 2012 11:47
-
-
Save Nilzor/1992686 to your computer and use it in GitHub Desktop.
Saving all local users to a text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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