This simple script (useful for workgroup environments), is useful for generating users have in a text file users.txt this file has the following 2 fields for each line are separated by commas: user, password, example would be this::
pepito,passworddepepito
jaimito,passworddejaimito
joselito,passworddejoselito
….
the script reads the file and generates the user adds them to the Administrators group and sets the password expiration to never.

' get local computer name
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("usuarios.txt", ForReading)
Do Until objTextFile.AtEndOfStream
  strNextLine = objTextFile.Readline
  arrServiceList = Split(strNextLine , ",")
  strAccount=arrServiceList(0)
  strPswd=arrServiceList(1)
  ' check if local account already exists
  intExists = 0
  Set colAccounts = GetObject("WinNT://" & strComputer & "")
  colAccounts.Filter = Array("user")
  For Each objUser In colAccounts
    If objUser.Name = strAccount Then
       intExists = 1
    End If
Next
If intExists = 0 Then
  ' create local user
  Set colAccounts = GetObject("WinNT://" & strComputer & "")
  Set objUser = colAccounts.Create("user", strAccount)
  ' set pswd
  objUser.SetPassword strPswd
  objUser.SetInfo
  ' set pswd never expires
  Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",User")
  objUserFlags = objUser.Get("UserFlags")
  objPasswordExpirationFlag = objUserFlags Or ADS_UF_DONT_EXPIRE_PASSWD
  objUser.Put "userFlags", objPasswordExpirationFlag
  objUser.SetInfo
  ' add to local admins group
  Set objGroup = GetObject("WinNT://" & strComputer & "/Administradores,group")
  Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",user")
  objGroup.Add(objUser.ADsPath)
End If
Loop
Facebooktwitterredditpinterestlinkedinmail