|
|
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" [/CACHE:Manual | Automatic | No
]
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 | devicename | drive:path} /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]
In the above command /USER can also be specified as:
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
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.
NET USE command can map a network printer to an LPT port (for DOS type applications that print to a port.) but this does not add the printer to Control Panel - Printers.
By default Mapped
drives, have a 15 minute idle session
timeout, you can modify this timeout with the NET
CONFIG command. This timeout affects NT/2K/XP but is visible in the XP
GUI.
To create file shares the SERVER service must be running, which in turn requires
'File and Print Sharing' to be installed.
Drive Descriptions
Windows 2000 and XP display a drive description in the MS Explorer
GUI, this is stored in the registry.
Win 2K stores a description for each drive letter, XP stores a description for
each share.
Win XP registry HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##ComputerName#ShareName _LabelFromReg=<description of drive mapping> (string REG_SZ) Windows 2000 registry HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints\DriveLetter\_LabelFromReg Cache = <description of drive mapping> (REG_BINARY data type)
You can edit the description in the registry or just use the Explorer GUI.
"Don't worry about people stealing an idea. If it's original, you will
have to ram it down their throats" - Howard Aiken
Related:
CON2PRT - Connect or disconnect a Printer
You can also map to a drive share using the pushd command
GLOBAL - Display membership of global groups
LOCAL - Display membership of local groups
OPENFILES - List or disconnect open files, local or remote (Win XP)
WMIC NETUSE - WMI access to drive mappings.
fsmgmt.msc - List or disconnect open files - (Win XP GUI)
Drmapsrv - Drive Share for use with Terminal Services (Win 2K Server Resource
Kit only)
Q138365 - Autodisconnect
(Red cross)
Q305355 - Drives
disconnected, and a red "X" appears
Q149427 - Change Password
from the CMD prompt
Slow Network Browsing (XP)
Equivalent Linux BASH commands:
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