Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 



How can I add a user from the command line?

RSS
Subscribe to Windows IT Pro | See More User Management and Profiles Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

A. A. The simple answer is to use the net user <username> <password> /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.bat

net user %1 password /add /homedir:\\<server>\users\%1 /scriptpath:login.bat /domain
net localgroup "<local group>" %1 /add
repeat for local groups
net group "<groups>" %1 /add /domain
repeat for global groups
xcopy \\<server>\users\template \\<server>\users\%1 /e
nltest /sync /server:BDCname
repeat for all BDCs you might be authenticating to
sleep 20
cacls \\<server>\users\%1 /e /r Everyone
remove the everyone permission to the directory
cacls \\<server>\users\%1 /g %1:F /e
cacls \\<server>\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.


End of Article



Reader Comments
Here is my problem:
I want to create accounts using the NET USER. I want to specify that Y: be mapped to \\servername\username$ in user manager. How do I do that using the NET USER command? I tried it and Z: is the default.
THANKS

Bigfaw September 26, 2000


I tried the addnew.bat batch file, but I found that it (i.e. the net user command) doesn't fill in the username in the Windows 2000 account field (however it does fill in the username in the pre-Windows 2000 field). Anyone have the same problem (or maybe a solution? Thanks in advance!

Johan Willems October 22, 2002


I would like to view a nukber of uxers access writes, I tried using net user and it gives me exactly what I want but I dont knowwhich switch to uses to add multipe user names ie net user bloggsb show me everthing b Bloogs has but if I want to see what bloogsb and fredx and willa I will have to type this several time can you help ?


Anonymous User November 08, 2004


how i can add adminstrator acount in windows 2000 using
cmd.exe

Anonymous User December 29, 2004


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Understanding File-Size Limits on NTFS and FAT

A general confusion about files sizes on FAT seems to stem from FAT32's file-size limit of 4GB and partition-size limit of 2TB. ...


Related Events WinConnections and Microsoft® Exchange Connections

Deep Dive into Windows Server 2008 R2 presented by John Savill

Cutting Costs with Client Management

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement