NET USE
The NET Command is used to connect to a File/Printer Share as follows:
Join a file share (Drive MAP) - Win 2K / XP / 2003 NET USE [driveletter:] \\ComputerName\ShareName\folder1\folder2 /PERSISTENT:No
The commands below work in NT 4 or greater -Make all future connections persistent (auto-reconnect at login)NET USE /Persistent:Yesor NET USE /P:Yes
Make all future connections non-persistent (reconnect with login script)NET USE /Persistent:NoorNET USE /P:No
Join a file share (Drive MAP)NET USE [driveletter:] \\ComputerName\ShareName /PERSISTENT:YES
Join a file share (Drive MAP) - with a "long" share nameNET USE [driveletter:] "\\ComputerName\ShareName"
Connect a user to their HOME directoryNET USE [devicename *] [password *]] [/HOME]This requires the users Home server/folder to be defined in ADUCJoin 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\ShareNameThis will be a little slower, but ensures that files can be read from the mapped drive immediately.Join a Printer ShareNET USE [LPTx:] \\ComputerName\printer_share /PERSISTENT:YESJoin a Printer Share - with a "long" share nameNET USE [LPTx:] "\\ComputerName\printer_share"Disconnect from a shareNET USE [driveletter:] /DELETE
Examples
NET USE H: /HomeNET USE H: \\MainServer\Users\%Username%NET USE W: \\MainServer\GroupShare /Persistent:NoNET USE \\MainServer\SharedPrinterNotes: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 all mapped drives have a 15 minute idle session timeout, you can modify this with the NET CONFIG command. This timeout does affect NT and 2000 but actually became visible in the XP GUI, this behaviour is to improve the overall performance.
Alternatives
Windows Scripting Host (WSH) provides alternative and arguably better commands, for XP and 2003 this is the way to go:Wsh.MapNetworkDrive [ example script ]Wsh.AddWindowsPrinterConnection [Examples]
Drive Descriptions
Recent versions of Windows display a drive description, this can be edited in the Explorer GUI. The text 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=
(string REG_SZ)
Windows 2000 registry
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints\DriveLetter\_LabelFromReg
Cache =
(REG_BINARY data type)
"Two roads diverged in a wood, and I-I took the one less traveled by,And that has made all the difference - Robert FrostRelated:CON2PRT - Connect or disconnect a PrinterNET - Manage network resourcesNET SHARE - Create file shareOPENFILES - List or disconnect open files, local or remote (Win XP)PUSHD - map to a drive shareRMTSHARE - List or edit a file share or print share (on any computer)RUNDLL32 - Add/remove print connectionsSHARE - List or edit a file share or print shareWMIC NETUSE - WMI access to drive mappingsWsh.MapNetworkDrive - Map DriveWsh.AddWindowsPrinterConnection - Connect to Printerfsmgmt.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" appearsSlow Network Browsing (XP)Equivalent Linux BASH commands:id - Print user and group id'slogname - Print current login nametty - Print filename of terminal on stdinuname - Print system informationusers - Print login names of users currently logged inwho - Print who is currently logged in
www.svdeals.com super value deals
No comments:
Post a Comment