My company's security-policy guidelines state that each month we must reset the passwords for all the Windows NT 4.0 accounts in one of our domains. Using the User Manager for Domains tool in the Windows GUI to perform this task is time-intensive. The same is true for creating new accounts. Can we use a command-line tool to input a text file that contains a list of user accounts and passwords?
Two command-line tools can help you: the For command and the Addusers command in the Microsoft Windows NT Server 4.0 Resource Kit. Few people know that the For command can read in lines from a delimited file. To resolve your problem, you could create a delimited text file called users.txt that uses a comma as a delimiter. In the file, add a list of usernames and their new passwords, as follows:
john, abcdefgh jackt, 12345678 jayc, hgfedcba mikek, 87654321
You can then use the following command to simultaneously reset all user account passwords:
for /F "delims=, tokens=1,2" %A in (users.txt) do net user %A %B
This command reads in the users.txt file line by line and populates the variables %A and %B with the values from the first and second fields in the users.txt file, as Figure 1 shows.
You can use For or Addusers to create new accounts and set their passwords. Use the following command and the users.txt file:
for /F "delims=, tokens=1,2" %A in (users.txt) do net user %A %B /add
To use Addusers to create new user accounts and set their passwords, use the following command, as Figure 2 shows:
addusers /c users.txt
When you use Addusers, the users.txt file will look like the following:
\[User\]john,,abcdefgh,,,,
jackt, 12345678,,,,
jayc, hgfedcba,,,,
mikek, 87654321,,,,