Microsoft KB Archive/140387

= Batch File Adds/Removes Machine Accounts in Server Manager =

Article ID: 140387

Article Last Modified on 2/20/2007

-

APPLIES TO


 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Professional Edition
 * Microsoft Windows NT Workstation 3.5
 * Microsoft Windows NT Workstation 3.51
 * Microsoft Windows NT Workstation 4.0 Developer Edition
 * Microsoft Windows NT Server 3.5
 * Microsoft Windows NT Server 3.51
 * Microsoft Windows NT Server 4.0 Standard Edition

-



This article was previously published under Q140387





SUMMARY
An Windows NT network administrator may have to add a large number of Windows NT Workstations or Non-Domain Controller Servers to a domain's Machine Account database, which is accessed and maintained by the Server Manager user interface.



MORE INFORMATION
In situations where a network administrator is setting up a network with a large number of new machine accounts, it may be advantageous to consider using a simple batch file to add all of the new machine accounts.

It is possible to add machine accounts with a command line utility under Windows NT called NET COMPUTER. Its syntax is:

NET COMPUTER \\computername [/ADD | /DELETE]

Using NET COMPUTER Command in a Simple Batch File
This example adds 5 new machine accounts to the domain:

echo ***** Are you sure you want to add these accounts? *******

echo *** If not, press CTRL-C to terminate this batch file ***

pause

net computer \\NT1 /ADD

net computer \\NT2 /ADD

net computer \\NT3 /ADD

net computer \\NT4 /ADD

net computer \\NT5 /ADD

cls

echo ******* Machine Accounts Added ********

pause

NOTE: The NET COMPUTER command listed in this article can only be used to add Windows NT Workstation or Windows NT Server (Non-Domain Controller role) machine accounts to the Server Manager's database. Also, this command or batch files that use this command should only be run at the Primary Domain Controller(PDC). Once the batch file is run the administrator can then synchronize the account database with the rest of the domain's Backup Domain Controller's (BDC's).

Using the FOR Batch File Command in Conjunction with NET COMPUTER
Another way to accomplish this is to use the FOR command. The batch file command FOR lets your batch file repeat a command for a specific set of files. In this case, for the specific machine names we want to add to the Server Manager database:

echo ***** Are you sure you want to add these accounts? *******

echo *** If not, press CTRL-C to terminate this batch file ***

pause

FOR %%X IN (NT1 NT2 NT3 NT4 NT5) DO NET COMPUTER \\%%X /ADD

FOR %%X IN (NT6 NT7 NT8 NT9 NT10) DO NET COMPUTER \\%%X /ADD

cls

echo ******* Machine Accounts Added ********

pause

NOTE: Under Windows NT, the command line is limited to 256 characters.

NET COMPUTER Errors

 * The NET COMPUTER command will return an error level message for each machine name that is attempted.
 * If the computer name already exists in the Server Manager database the message: "The computer \\name already exists." is returned with a NET HELPMSG #3782.
 * If the command completed successfully, a message saying so appears.

Using NET COMPUTER to Delete Many Machine Accounts
You can also remove many accounts by using the "\DEL" switch instead of the "\ADD" switch in the batch files shown above.

Additional query words: prodnt Computer Account

Keywords: kbsetup kbusage KB140387

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.