How can I add a user from the command line?
Learn how to add a user from the command line.
John Savill
April 16, 2000
1 Min Read
A. The simple answer is to use the net user /add (/domain) , however it is possible to automate not only the addition of the user, but also his/her addition to groups and the creation of a template user account directory structure. Many organizations have a basic structure with word, excel directories and some template files. This can be automated with a basic script. For example
addnew.batnet user %1 password /add /homedir:\users%1 /scriptpath:login.bat /domainnet localgroup "" %1 /addrepeat for local groupsnet group "" %1 /add /domainrepeat for global groupsxcopy \userstemplate \users%1 /enltest /sync /server:BDCnamerepeat for all BDCs you might be authenticating tosleep 20cacls \users%1 /e /r Everyoneremove the everyone permission to the directorycacls \users%1 /g %1:F /ecacls \users%1 /g Administrators:F /e
The nltest commands are needed as otherwise it fails to do the cacls command, since the user account does not exist on the BDC to which you are authenticating as only the PDC has been updated.
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like