NT Syntax

NET.exe

The NET Command is used to manage File Shares, Printer Shares and sessions as follows:

Display a local share
NET SHARE sharename

Display a list of computers in the current domain.
NET VIEW

To see a list of shares on a remote computer
NET VIEW \\ComputerName

To see a list of all shares in the domain:
NET VIEW /DOMAIN

To see a list of shares on a different domain
NET VIEW /DOMAIN:domainname

To see a list of shares on a remote Netware computer
NET VIEW /NETWORK:NW [\\ComputerName]

Create a new local file share
NET SHARE sharename=drive:path /REMARK:"text"

Limit the number of users who can connect to a share
NET SHARE sharename /USERS:number /REMARK:"text"

Remove any limit on the number of users who can connect to a share
NET SHARE sharename /UNLIMITED /REMARK:"text"

Delete a share
NET SHARE sharename /DELETE

Delete all shares that apply to a given device
NET SHARE devicename /DELETE
In this case the devicename can be a printer (Lpt1) or a pathname (C:\Docs\)

Join a file share (Drive MAP)
NET USE [driveletter:] \\ComputerName\ShareName /PERSISTENT:YES

Join a file share (Drive MAP) - Win 2K / XP
NET USE [driveletter:] \\ComputerName\ShareName\folder1\folder2 /PERSISTENT:YES

Join a file share (Drive MAP) - with a "long" share name
NET USE [driveletter:] "\\ComputerName\ShareName"

Join a password protected file share (Drive MAP)
NET USE [driveletter:] \\ComputerName\ShareName[\volume] [password | *]
[/USER:[domainname\]username] [/PERSISTENT:YES]

Join a file share (Drive MAP) and wait before continuing
START /wait NET USE [driveletter:] \\ComputerName\ShareName

Join a Printer Share
NET USE [LPTx:] \\ComputerName\printer_share /PERSISTENT:YES

Join a Printer Share - with a "long" share name
NET USE [LPTx:] "\\ComputerName\printer_share"

Connect a user to their HOME directory
NET USE [devicename | *] [password | *]] [/HOME]

Disconnect from a share
NET USE [driveletter:] /DELETE

Change the default connection type
NET USE [/PERSISTENT:{YES | NO}]

Display all the open shared files on a server and the lock-id
NET FILE

Close a shared file (disconnect other users and remove file locks)
NET FILE id /CLOSE

List all sessions connected to this machine
NET SESSION

List sessions from a given machine
NET SESSION \\ComputerName

Disconnect all sessions connected to this machine
NET SESSION /DELETE

Disconnect all sessions connected to this machine (without any prompts)
NET SESSION /DELETE /y

Disconnect sessions from a given machine
NET SESSION \\ComputerName /DELETE

Notes:
NET SESSION displays incoming connections only, in other words it must be run on the machine that is acting as the server.
To create file shares the SERVER service must be running

Related commands:

CON2PRT
- Connect or disconnect a Printer
You can also map to a drive share using the pushd command
Change Password from the CMD prompt - Q149427
GLOBAL - Display membership of global groups
LOCAL
- Display membership of local groups
Drmapsrv - Drive Share for use with Terminal Services (Win 2K Server Resource Kit only)

Equivalent Linux BASH commands:

groups - Print group names a user is in
hostname - Print or set system name
id - Print user and group id's
logname - Print current login name
tty - Print filename of terminal on stdin
uname - Print system information
users - Print login names of users currently logged in
who - Print who is currently logged in



Simon Sheppard
SS64.com