Reader to Reader - Scripting Solutions - 01 Mar 1999


\[Editor's note: Email your scripting solutions (400 words or less) to R2R at [email protected]. Please include your script and your phone number. We will edit submissions for style, grammar, and length. If we print your contribution, you'll get $100.\]

Many Windows NT administrators need a means for adding users to a domain in batches. At the beginning of each semester, I use a short batch command file (AddUsers.cmd) to add about 30,000 accounts to my domain.

Using the AddUsers.cmd script is simple. In Microsoft Access or Microsoft Excel, you create a semicolon-delimited text file (userfile.txt) that contains the user accounts. Each line in this input file contains the following information:

Username;Full name;Password;Comment;Expires;Password Change;Logon Script

For example, the line to add a user account for John Doe might look like

jdoe;Doe, John;JohnPAssword;New User;Never;No;logonscr.bat

AddUsers.cmd reads from this text file and uses the NET USER command to add each account. Because NET USER has many switches that you can use, you can add user accounts that are complete.

I recommend that you run the script from the Primary Domain Controller (PDC). Otherwise, the script takes too long to run. I use the AT command to schedule the script to run late at night on the PDC. On a dual-Pentium Pro 200 processor, the operation to add 30,000 accounts takes about 75 minutes.

Listing 1 contains an excerpt from AddUsers.cmd. You can find the entire AddUsers.cmd script on the Win32 Scripting Journal Web site. This script is set up to run as a batch file. To run the script from the command line, you need to use only one percent character (%) for the variables. You can easily modify this script (and the accompanying input text file) to set other account settings or to delete or modify accounts. For more information about other account settings, type

net help user 

from the command prompt.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.