Description: Checks to see if a local user account exists on a pc.
Option Explicit
'On Error Resume Next
'Define Variables
Dim CompName1, objEnvVar1, OSName1, RunNetUser, Fso, FileExist, Line1, CMD
Dim TempDir, OpenFile, Line1Test
' Set up an Instance of the WScript.Shell Object and access Env var Computer Name
Set objEnvVar1 = WScript.CreateObject("WScript.Shell")
OSName1 = objEnvVar1.ExpandEnvironmentStrings("%OS%")
CompName1 = objEnvVar1.ExpandEnvironmentStrings("%ComputerName%")
CMD = objEnvVar1.ExpandEnvironmentStrings("%ComSpec% /K")
TempDir = objEnvVar1.ExpandEnvironmentStrings("%Temp%")
RunNetUser = ObjEnvVar1.Run(CMD & " Net User ChangetoRequiredUserName > %Temp%\NetUser.txt" , 0, False)
WScript.Sleep 1000
Set Fso = Createobject("Scripting.FileSystemObject")
FileExist = Fso.FileExists(TempDir & "\NetUser.txt")
If FileExist = True Then
Set OpenFile = Fso.OpenTextfile(TempDir & "\NetUser.txt", 1)
Do While OpenFile.AtEndOfStream = False
Line1 = Openfile.ReadAll
Loop
If line1 = "" Then
MsgBox "User Account Does Not Exist"
Else
MsgBox "User Account Exists"
End If
End If
Set CompName1=Nothing
Set objEnvVar1=Nothing
Set OSname1=Nothing
Set RunNetUser=Nothing
Set Fso=Nothing
Set FileExist=Nothing
Set Line1=Nothing
Set CMD=Nothing
Set TempDir=Nothing
Set OpenFile=Nothing
Set Line1Test=Nothing
'On Error Goto 0
WScript.Quit