March 10th 1997 Mirror Sites ![]() Download the Software Network Card Drivers ![]() Features User's Guide Help ![]() Search Distribution Rights Listserv Shareware Links ![]() 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
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 SHAREThis 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 driveThere 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 nameSyntax: 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 directorySometimes 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 nameSyntax: 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 rightsThere 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 rightsTo 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. PasswordsA 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 passwordsTo 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 driveIf 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 directoryIf 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 printerThere 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 nameSyntax: 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 rightsAccess rights have no effect when sharing a printer.PasswordsA 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 passwordsTo 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 printerIf 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 portThere 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 nameSyntax: 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 rightsAccess rights have no effect when sharing serial ports.PasswordsA 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 passwordsTo 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 portIf 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 listYou 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: ![]() 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. TipsA 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 Messages34h Duplicate name on networkDisplayed 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. [Chapter 4] [Chapter 2] [Table of Contents] [Home Page] | |||||||||||||||||||||||||||||
![]() | ![]() | ![]() |