NetSoft Computer Networks
Last Updated
March 10th
1997

Mirror Sites
NetSoft LAN
Download the
Software

Network Card
Drivers

Secure
Features
User's Guide
Help
VeriSign

Search
Distribution
Rights

Listserv
Shareware Links
Order Now
Order the
Software

Help Us
Promote
NetSoft LAN

Dealer
Enquires
Welcome

Home Page
http://www.netsoft.ie/
CHAPTER 3

The NET Command


NET Command Syntax Chart


SymbolsPurpose
{ }Braces indicate a parameter you must use
[ ]Brackets indicate an optional parameter
|Bar indicates a choice of parameters
d:Indicates a drive letter from A: to Z: (LASTDRIVE= parameter must be set in your CONFIG.SYS file if you wish to use drives F: through Z:)
pathIndicates a drive and directory (e.g. C:\ACCOUNTS)
password1-8 or 1-16 character password
/rights/R /W /RW /WC /RWC Read, Write, Create (only take effect if PROTECT.COM is loaded)
deviceA DOS device name: PRN, LPT1, LPT2, LPT3 or LPT4, COM1, COM2, COM3 or COM4
network name1-8 characters that represent a drive and path or device name
computername1-15 characters identifying a computer starting with a double backslash ('\\')
number1-25 digit telephone number that may include Hayes dial syntax commands
commandAny valid NET command or sub command
/dIndicates that you wish to cancel a previous NET SHARE command or NET USE command

You must include all punctuation (except braces, brackets and bars) such as periods, equal signs, forward slashes and backslashes, where illustrated in the syntax.

NET SHARE


This command allows a device or drive to be shared with other users on the network. The device may be a printer connected to LPT1 through LPT4, a serial port COM1 through COM4, a drive A: through Z:, or a directory.

The NET SHARE command is only available on a server configuration. In other words, you must have previously loaded either DOSNET.COM or SERVER.COM.

Before any network users can use a device or drive, it must have been previously shared using the NET SHARE command from the server machine.

If you are familiar with the NET SHARE command and just need to refresh your memory, simply read the Command Syntax In Brief.

If you are not familiar with the NET SHARE command, it is recommended that you read the Command Syntax In Depth.

All NET SHARE commands are provided in a pop-up menu form using the DOS-NET Station Manager. The Station Manager (SM.COM) may be accessed through the DOS-NET Main Menu using the network keys CTRL+ALT+Right Shift simultaneously.

Command Syntax In Brief

Sharing a drive or directory

NET SHARE {d:}[path] [password | *] [/rights]

Sharing a drive or directory using a network name

NET SHARE {network name}={d:}[path] [password | *] [/rights]

Sharing a printer or serial port

NET SHARE {device} [password] | *] [/rights]

Sharing a printer or serial port using a network name

NET SHARE {network name}={device} [password] | *] [/rights]

Stop sharing a drive or directory

NET SHARE {d:}[path] /d

Stop sharing a drive or directory using a network name

NET SHARE {network name} /d

Stop sharing a printer or serial port

NET SHARE {device} /d

Stop sharing a printer or serial port using a network name

NET SHARE {network name} /d

Displaying the share list

NET SHARE

Command Syntax In Depth

Sharing a drive

There are two methods for sharing a complete drive. The first method is to simply specify the drive you wish to share. The second allows you to specify a logical network name to the drive.

Syntax: NET SHARE {d:}[path] [password | *] [/rights]

To share the C: drive. use the following command:

NET SHARE C:

The C: drive is now available to other network users. They must use the NET USE command to connect to the shared C: drive. It is preferable, however, to share using a network name.

Sharing a drive with a network name

Syntax: NET SHARE {network name}={d:}[path] [password | *] [/rights]

To share the C: using a network name, use the following command:

NET SHARE MYDRIVE=C:

The C: drive is now available to other network users as a network name. They must use the NET USE command specifying the network name before they can connect to the shared C: drive.

The advantage of using a network name over sharing the drive directly, is that the server can change the drive letter to a different drive letter such as D: at a later date, without having to change the client machine's NET USE command. The clients simply connect to whatever drive is associated with the network name MYDRIVE. This gives the server greater control of shared drives, without affecting clients.

Sharing a directory

Sometimes it is preferable to share a specific directory only, rather than an entire drive with other network users. The following commands share a directory directly and using a network name.

When other network users connect to a shared directory they are limited to that directory. This means they cannot change to another directory on the same drive.

Syntax: NET SHARE {d:}[path] [password | *] [/rights]

To share the C:\ACCOUNTS directory, use the following command:

NET SHARE C:\ACCOUNTS

The C:\ACCOUNTS directory is now available to other network users. They must use the NET USE command to connect to the shared C:\ACCOUNTS directory. It is preferable to assign a network name to the directory when sharing it.

Sharing a directory using a network name

Syntax: NET SHARE {network name}={d:}[path] [password | *] [/rights]

To share the C:\ACCOUNTS directory using a network name, type the following command.

NET SHARE PAYROLL=C:\ACCOUNTS

The C:\ACCOUNTS directory is now available to other network users as a network name. They must use the NET USE command, specifying the network name before they can connect to the shared C:\ACCOUNTS directory.

The advantage of using a network name over sharing the directory name, is that the server can change the drive and directory name (e.g. to as D:\PAY95 at a later date), without having to change the client machine's NET USE command.

The clients simply connect to whatever drive and directory is associated with the network name PAYROLL. This gives the server greater control of shared drives and directories.

Access rights

There are three types of access rights you may assign with each NET SHARE command. These are Read, Write and Create and are abbreviated to /R, /W and /C. You may use any combination of access rights for a particular NET SHARE command.

If no access rights are specified on the NET SHARE command line, then full access rights (/RWC) are assigned by default (i.e. Read, Write and Create).

Assigning access rights

To assign read only access rights to the C:\ACCOUNTS directory, type the following command:

NET SHARE PAYROLL=C:\ACCOUNTS /R

The command line must include the forward slash immediately before the R (Read attribute).

Access rights apply to entire shared drives as well as shared directories. If a user or server application attempts to violate their assigned access rights they will receive an error message to the effect of "Access Denied".


NOTE Because access rights are normally not required onsmall networks, the above rights only take effect after the PROTECT.COMutility has been loaded on the machine that is sharing the driveor directory.

Passwords

A password may be specified on the NET SHARE command line. If a password is specified, then all network users must specify the same password on their NET USE command line, before they are granted access to the shared drive or directory.

Assigning passwords

To assign a password SECRET to the C:\ACCOUNTS directory, use the following command.

NET SHARE PAYROLL=C:\ACCOUNTS /R SECRET

The password must be specified after any access rights are assigned as shown above.


NOTE The PROTECT.COM program is not required for password only protection.

Stop sharing a drive

If you make a mistake, or simply wish to cancel a particular NET SHARE command, you must use the /delete parameter. This is abbreviated to /d.

Syntax: NET SHARE {network name} /d

or

Syntax: NET SHARE {d:} /d

To delete the shared status of C: drive, type the following command:

NET SHARE C: /d

The command line must include the forward slash immediately before the d (delete attribute).

Stop sharing a directory

If you wish to stop sharing a shared directory, you must use the /delete parameter. This is abbreviated to /d.

Syntax: NET SHARE {network name} /d

or

Syntax: NET SHARE {d:}[path] /d

To delete the shared status of the C:\ACCOUNTS directory that was originally shared using the network name PAYROLL, use the following command:

NET SHARE PAYROLL /d

The command line must include the forward slash immediately before the d (delete attribute).


NOTE When you cancel a NET SHARE command using the /d parameter, users already connected to that drive or directory are not affected, and may continue working. They must disconnect, using the NET USE /d command if they wish to disconnect from the drive or directory. They are also automatically disconnected if they re-boot their machine.

Sharing a printer

There are two methods for sharing a printer. The first is to simply specify the printer port device you wish to share. The second allows you to assign a logical network name to each printer.

Syntax: NET SHARE {device} [password | *]

To share the printer connected to LPT1, type the following command:

NET SHARE LPT1

The LPT1 printer is now available to other network users. They must use the NET USE command to connect to the shared printer on LPT1. It is preferable to assign a network name to the printer when sharing it.

Sharing a printer with a network name

Syntax: NET SHARE {network name}={device} [password | *]

To share the printer connected to LPT1 using the network name LASER, use the following command::

NET SHARE LASER=LPT1

The printer connected to LPT1 is now available to other network users as a network name. They must use the NET USE command specifying the network name, before they can connect to the shared printer.

The advantage of using a network name over sharing the printer port name is that the server can change the printer port device name (e.g. to LPT2), at a later date, without having to change the client machine's NET USE command. The clients simply connect to whatever printer is associated with the network name LASER. This gives the server greater control of shared printers.

Access rights

Access rights have no effect when sharing a printer.

Passwords

A password may be specified on the NET SHARE command line. If a password is specified, then all network users must specify the same password on their NET USE command line, before they are granted access to the shared printer.

Assigning passwords

To share the printer connected to LPT1 using a network name and to assign a password called SECRET to that printer, use the following command:

NET SHARE LASER=LPT1 SECRET

The printer connected to LPT1 known as LASER is now available to other network users as a network name. They must use the NET USE command specifying the network name and the password SECRET before they can connect to the shared printer.


NOTE The SPOOLER.COM program must be loaded on the print server before any network users can print to the network printer.

Stop sharing a printer

If you make a mistake or simply wish to cancel a particular NET SHARE command you must use the /delete parameter. This is abbreviated to /d.

Syntax: NET SHARE {network name} /d

or

Syntax: NET SHARE {device} /d

To delete the shared status of LPT1 or LASER, type the following command:

NET SHARE LPT1 /d

or

NET SHARE LASER /d

The command line must include the forward slash immediately before the d (delete attribute).


NOTE When you cancel a NET SHARE command using the /d parameter, users already connected to that printer are not affected and may continue working. They must disconnect using the NET USE /d command if they wish to disconnect from the printer. They are also automatically disconnected if they re-boot their machine.

Sharing a serial port

There are two methods for sharing a serial port. The first is to simply specify the serial port device you wish to share. The second allows you to assign a logical network name to the serial port.

Syntax: NET SHARE {device} [password | *]

To share the serial port COM1, use the following command:

NET SHARE COM1

The COM1 serial port is now available to other network users. They must use the NET USE command to connect to the shared serial port on COM1. It is preferable to assign a network name to the serial port when sharing it.

Sharing a serial port with a network name

Syntax: NET SHARE {network name}={device} [password | *]

To share the serial port COM1 using the network name COMPORT, use the following command:

NET SHARE COMPORT=COM1

The serial port COM1 is now available to other network users as a network name. They must use the NET USE command specifying the network name, before they can connect to the shared serial port.

The advantage of using a network name over sharing the serial port device name is that the server can change the serial port device name (e.g. to COM2) at a later date, without having to change the client machine's NET USE command. The clients simply connect to whatever serial port is associated with the network name COMPORT. This gives the server greater control of shared serial ports.

Access rights

Access rights have no effect when sharing serial ports.

Passwords

A password may be specified on the NET SHARE command line. If a password is specified, then all network users must specify the same password on their NET USE command line, before they are granted access to the shared serial port.

Assigning passwords

To share the serial port COM1 using a network name and to assign a password called SECRET to that serial port, use the following command:

NET SHARE COMPORT=COM1 SECRET

The COM1 serial port known as COMPORT is now available to other network users as a network name. They must use the NET USE command, specifying the network name and the password SECRET, before they can connect to the shared serial port.


NOTE The COMREDIR.COM program must be loadedon both the serial port server and the serial port client machines,before any network users can use the shared serial ports.

Stop sharing a serial port

If you make a mistake, or simply wish to cancel a particular NET SHARE command you must use the /delete parameter. This is abbreviated to /d.

Syntax: NET SHARE {network name} /d

or

Syntax: NET SHARE {device} /d

To delete the shared status of COM1 or COMPORT, use one of the following commands:

NET SHARE COMPORT /d

The command line must include the forward slash immediately before the d (delete attribute).


NOTE When you cancel a NET SHARE command using the /d parameter, users already connected to that serial port are not affected and may continue working. They must disconnect using the NET USE /d command if they wish to disconnect from the serial port. They are also automatically disconnected if they re-boot their machine.

Displaying the share list

You can verify the shared status of any shared resources using the NET SHARE command with no parameters.

Let us assume the following NET SHARE commands were executed prior to displaying the share list:

NET SHARE C:

NET SHARE PAYROLL=C:\ACCOUNTS /RW

NET SHARE LASER=LPT1 SECRET

NET SHARE COMPORT=COM1 SECRET

The above NET SHARE commands share the C: drive, the C:\ACCOUNTS directory using the network name PAYROLL, with read-and-write access rights.

The LPT1 printer was also shared using the network name LASER, and protected using the password SECRET. Finally the COM1 serial port was also shared using the network name COMPORT and was also protected with the password SECRET.

To verify the status of all shared resources use the following commands:

NET SHARE

A list similar to the following will be displayed:

NET SHARE

In this case, all NET SHARE commands were successful. Because a network name was not used with our first NET SHARE C: command, the display shows [No Name], and because access rights were not specified, full access rights were assigned by default.

A password is required for the last two NET SHARE commands. The passwords themselves are not displayed, only the fact that these devices require a password.

Tips

A maximum number of 100 NET SHARE commands may be performed.

When configuring a server machine, set the number of Shortnames= parameter in the DOSNET.INI file to the maximum number that you are actually going to use. Setting the Shortnames= parameter to a large value, wastes memory.

On a client-only configured machine, the Shortnames= parameter in the DOSNET.INI file is automatically set to 0 to save memory, as client-only configurations cannot share their resources.

The NetBIOS module does not need to be loaded for the NET SHARE command.

The NET SHARE command is not related to the DOS SHARE.EXE command.

NET SHARE commands may be issued from within your AUTOEXEC.BAT file at start-up. NET USE commands should not be issued from your AUTOEXEC.BAT file. One or more servers you may be connecting to, may not be powered on, or may not have the network software loaded before you try to make your connections.

Related Error Messages

34h Duplicate name on network

Displayed when trying to NET SHARE a drive, printer or serial port. This is because the name is already assigned. You can verify this using the Displaying The Share List command (NET SHARE with no parameters).

35h or 43h Network name not found

When trying to connect to a device, drive or network name on a server, check your syntax and make sure you are specifying the correct device, drive or network name. Also, check that the name has been shared on the server you are specifying.

44h Network name limit exceeded

Either delete some network names using the /d parameter, or increase the number of Shortnames= parameter in the DOSNET.INI file.

42h Network device type incorrect

When you are trying to connect a local drive letter to a remote printer name, or a local printer to a remote drive letter, check your syntax.


[Top of Page]
[Chapter 4] [Chapter 2]
[Table of Contents] [Home Page]

Prices and World Wide Ordering Information

Copyright © 1997 NetSoft Computer Networks. All Rights Reserved.
20 Sea Road, Galway, Ireland.
Tel (353)+91-529607.