NET USE
The NET Command
is used to connect to a File/Printer Share as follows:
Join a file
share (Drive MAP)
NET USE [driveletter:] \\ComputerName\ShareName /PERSISTENT:YES
NET USE [driveletter:] \\ComputerName\ShareName /PERSISTENT:YES
NET
USE [driveletter:] \\ComputerName\ShareName\folder1\folder2
/PERSISTENT:No
Make all
future connections persistent (auto-reconnect at login)
NET USE /Persistent:Yes
or
NET USE /P:Yes
NET USE /Persistent:Yes
or
NET USE /P:Yes
Make all
future connections non-persistent (reconnect with login script)
NET USE /Persistent:No
or
NET USE /P:No
NET USE /Persistent:No
or
NET USE /P:No
Join a file
share (Drive MAP) - with a long share name
NET USE [driveletter:] "\\ComputerName\ShareName"
NET USE [driveletter:] "\\ComputerName\ShareName"
Connect a
user to their HOME directory
NET USE [devicename | *] [password | *]] [/HOME]
This requires the users Home server/folder to be defined in ADUC
Join a password protected file share (Drive MAP)
NET USE [driveletter:] \\ComputerName\ShareName[\volume] [password | *] [/USER:[domainname\]username] [/PERSISTENT:No]
In the above command /USER can also be specified as:
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
In a script, to map a drive and wait until the mapping has completed before continuing:
START /wait NET USE [driveletter:] \\ComputerName\ShareName
This will be a little slower, but ensures that files can be read from the mapped drive.
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"
Disconnect from a share
NET USE [driveletter:] /DELETE
NET USE [devicename | *] [password | *]] [/HOME]
This requires the users Home server/folder to be defined in ADUC
Join a password protected file share (Drive MAP)
NET USE [driveletter:] \\ComputerName\ShareName[\volume] [password | *] [/USER:[domainname\]username] [/PERSISTENT:No]
In the above command /USER can also be specified as:
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
In a script, to map a drive and wait until the mapping has completed before continuing:
START /wait NET USE [driveletter:] \\ComputerName\ShareName
This will be a little slower, but ensures that files can be read from the mapped drive.
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"
Disconnect from a share
NET USE [driveletter:] /DELETE
Disconnect
from a share and close all resources (undocumented)
NET USE [driveletter:] /DELETE /Y
NET USE [driveletter:] /DELETE /Y
Examples
NET USE H:
/Home
NET USE J: \\MainServer\Users\%Username%
NET USE W: \\MainServer\GroupShare /Persistent:No
NET USE \\MainServer\SharedPrinter
Notes:
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 the Control Panel GUI.
NET USE J: \\MainServer\Users\%Username%
NET USE W: \\MainServer\GroupShare /Persistent:No
NET USE \\MainServer\SharedPrinter
Notes:
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 the Control Panel GUI.
By default
all mapped drives have a 15 minute idle session timeout, you can modify
this with the NET CONFIG command. In windows XP the explorer
icon will change to show this change in status, this behaviour is designed to
improve overall performance.
Drive
Descriptions
Recent
versions of Windows display a drive description for each share, this can be
edited in the Explorer GUI. The text is stored in the registry.
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##ComputerName#ShareName
_LabelFromReg=<description of drive mapping>
(string
REG_SZ)
No comments:
Post a Comment