Link to home
Start Free TrialLog in
Avatar of meepmaker
meepmaker

asked on

Anyone got a vbs script to create multiple user accounts (local) ?

Hi,
I need a generic .vbs script to run on non-Active Directory servers (Windows 2003) to create multiple local user accounts.  I found a vbs script that references a excel spreadsheet with 2 columns (Username; Password) - this worked well when I tested on my XP desktop, which had excel installed.  Unfortunately all of the servers I need to create the multiple accounts do not have excel installed, so this script didn't work.
Therefore it would be great if anyone could suggest a script to run which could reference a text file etc.  It would also be useful if the script included the appropriate switch for the account passwords not expire.
Sorry, I'm not a scripter, so this is a bit of a challenge for me & I've got a deadline.
Thanks...
Avatar of rlandquist
rlandquist
Flag of United States of America image

Here is a script to do just that.  Add as many users to the array at the top, set the password to what you want, and away you go.
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

arrUsers = Array("User1", "User2", "User3")
strComputer = "rlandquist-w7"
Set colAccounts = GetObject("WinNT://" & strComputer & "")

For Each strUser In arrUsers
    Set objUser = colAccounts.Create("user", strUser)
    objUser.SetPassword "test"
    objUser.SetInfo
            
    Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",User")
    
    objUserFlags = objUser.Get("UserFlags")
    objPasswordExpirationFlag = objUserFlags Or ADS_UF_DONT_EXPIRE_PASSWD
    objUser.Put "userFlags", objPasswordExpirationFlag 
    objUser.SetInfo
Next

Open in new window

forgot to change the computer name.  You can set it to "." so it does not need to be changed for each server.
Avatar of meepmaker
meepmaker

ASKER

Thanks rlandquist,

However, I was looking to state the passwords associated with each account created.  I'll be creating the same 20 accounts on 22 servers.  From what I can see on the script you gave it states the password to be the same "test" for every user.  I would then have to reset the password for each account. The servers I intend to run this on hold sensitive data and therefore they have to be unique or at.
I can modify for different passwords.  You did not specify that, so I did not know it was a requirement.

How many accounts are you creating?
Sorry, 20 accounts are being created on each server, & each will have a different password.
ASKER CERTIFIED SOLUTION
Avatar of rlandquist
rlandquist
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent concise answer.