Question Locked

Non-Domain WinXP: Creating Multiple Local User Accounts

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Have about 50 WinXP clients in a non-domain controled environment. What is required is that all Users have access to any PC using their own credentials. Does anyone know of a way to create a batch-file or a script that can be run on each machine to add to the Local Users Group?

Thanks

3 replies

by Member 25348569

Put the list of users in a file. You will have to run this on each system.

' -----------------------------------
Const ForReading = 1

strUserFile = "path to your file"
Set objNetwork = CreateObject("wscript.network")
strComputer = objNetwork.ComputerName

Set objFSO = CreateObject("scripting.filesystemobject")
Set oUserFile = oFSO.OpenTextfile(strUserFile,ForReading)

Set objGroup = GetObject("WinNT://" & strComputer & "/Users,group")

Do while Not oUserFile.AtendOfStream
strUser = oUserFile.ReadLine
Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user")
objGroup.Add(objUser.ADsPath)
Loop

wscript.echo "Done"

' -----------------------------------

An alternative Is To hard-code the users into the program. Clunky but OK For a one-off shot

Set dUserList = CreateObject("scripting.dictionary")
dUserList.Add "John",1
dUserList.Add "Bill",1
'etc

Set objNetwork = CreateObject("wscript.network")
strComputer = objNetwork.ComputerName

Set objFSO = CreateObject("scripting.filesystemobject")
Set oUserFile = oFSO.OpenTextfile(strUserFile,ForReading)

Set objGroup = GetObject("WinNT://" & strComputer & "/Users,group")

For Each strUser In dUserList
Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user")
objGroup.Add(objUser.ADsPath)
Next

wscript.echo "Done"

' -----------------------------------

I'm on-call tonight so I'm bored so you get some help.

Neil :D

It suddenly occurred to me that you might not know to save between the lines into a file with a .vbs extension and just double-click it.

by julliadarc

Hi Neil,

I tried using these scripts and got error on both of them. Can you please tell me how the file has to be txt. or xls. and how the file should look like?

Thanks!!!!

Ju.

This discussion is closed to new replies.