Automate and simplify network and
administrative tasks
The NET commands in Windows NT are a set of networking and administrative
commands that are useful to the administrator and of interest to the beginner
investigating how NT works. With an understanding of the NET commands, you can
simplify NT systems maintenance, especially when you use them in batch files. In
this article, I'll show some of the more useful NET commands and suggest uses
for them.
What Are the NET Commands?
You run the NET commands from a command prompt or from within a batch file,
and they perform network and administrative tasks. Typical tasks include
establishing network connections, adding users and computers to a domain, and
starting and stopping network services.
One of the first uses that most people find for the NET command is during
an over-the-network installation of NT or some other software. Typically, you
connect to the server using the DOS client software and establish a connection
to the server. Then you use the NET USE command to map a network drive that
contains the source files for your new operating system. If you've created a
share called i386 that has the source code, the syntax is
net use M: \\server\i386
to map the shared i386 directory on the server to the M: drive on the local
computer. The next step is to switch to the M: drive and run the install or
setup program.
Where Can I Find a List of NET Commands?
The first place to look for a list of NET commands is the command prompt
from which you will run them. Type
net /?
to show the list of commands in Screen 1, page 214. To get more detailed
help for a specific command, type
net help <command>
For example, to learn the correct syntax for the NET COMPUTER command, type
net help computer
A second place to look for a list of these commands is Windows NT Help--not
Books Online, just the ordinary Help option on the Start menu. Choose the Find
tab in the Help dialog box, and search on "net." Display the topic
Commands Index for a listing similar to Screen 2, page 214. Be sure to search on
net in lowercase, because you will see a different set of topics if you search
on "Net."
Network Connections
As I mentioned earlier, you map a network drive with the NET USE command.
You can put such a command into a logon script, ensuring that all users connect
to the server with the same drive letter--something many network applications
require. On its own, NET USE will list your existing connections. Follow the
command with /del or /delete to drop the connection or /Persistent:yes to ensure
that the connection is rebuilt when you log on again.
You can do the same thing with printers when you have DOS or Windows 3.1
programs that do not recognize network printers. The syntax is similar, except
that this time, you use
net use lpt2: \\server1\HPLJ5
to map the network printer to a printer port that the DOS program
understands. Now your DOS program can send its output to LPT2 and not even
realize that it is talking to a network printer.
User and Group Accounts
You can add users and groups to a domain using NET commands. The NET USER
command adds usernames, passwords, and other settings to the accounts database.
The NET GROUP command adds global groups, and NET LOCAL GROUP adds local
groups.
You can even add users to the groups you create and obtain lists of group
memberships. In fact, you can use this feature to move users from one domain to
another. (If you've worked with NT, you know that to migrate users from one
domain to another, there is no easy way short of deleting thousands of users
from one domain and entering them again in another domain.) NET USER lets you
add users and, when you use it with no parameters, provides a list of users. The
same rule applies to NET LOCALGROUP and NET GROUP. Suppose that you want to move
everyone in the Engineering global group to another domain. The procedure is
1. Run the NET GROUP Engineering command to get a list of users, as Screen 3 shows.
2. Redirect this listing to a text file.
net group engineering >eng.txt
3. Using your favorite word processor, reformat the information to a batch
file that contains the NET USE commands to add these users to the new domain.
The batch file needs to contain one line per user and looks like:
net user <name> [password] /add/domain
4. Reformat the batch file to also contain the NET GROUP command to add the
users to the Engineering group. This batch file needs to contain a line
net group engineering /add <name>
for each user, but you can put multiple names on one line if you want.
5. Run the batch files on the new domain.