Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

April 17, 2000 12:00 AM

How can I add a user from the command line?

Windows IT Pro
InstantDoc ID #15064
Rating: (13)

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.


Related Content:

ARTICLE TOOLS

Comments
  • Anonymous User
    8 years ago
    Dec 29, 2004

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

  • Anonymous User
    8 years ago
    Nov 08, 2004

    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 ?

  • Johan Willems
    10 years ago
    Oct 22, 2002

    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!

  • Bigfaw
    12 years ago
    Sep 26, 2000

    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

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.