How to use windows net use

Net use

Applies To: Windows Server 2003, Windows Vista, Windows XP, Windows Server 2008, Windows 7, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2000, Windows Server 2012, Windows 8

Connects a computer to or disconnects a computer from a shared resource, or displays information about computer connections. The command also controls persistent net connections. Used without parameters, net use retrieves a list of network connections.

For examples of how this command can be used, see Examples.

Syntax

Parameters

Assigns a name to connect to the resource or specifies the device to be disconnected. There are two kinds of device names: disk drives (that is, D: through Z:) and printers (that is, LPT1: through LPT3:). Type an asterisk (*) instead of a specific device name to assign the next available device name.

Specifies the name of the server and the shared resource. If ComputerName contains spaces, use quotation marks around the entire computer name from the double backslash (\\) to the end of the computer name (for example, «\\ComputerВ Name\ShareВ Name»). The computer name can be from 1 to 15 characters long.

Specifies a NetWare volume on the server. You must have Client Service for NetWare or Gateway Service for Netware (Windows Server) installed and running to connect to NetWare servers.

Specifies the password needed to access the shared resource. Type an asterisk (*) to produce a prompt for the password. The password is not displayed when you type it at the password prompt.

Specifies a different user name with which the connection is made.

Specifies another domain. If you omit DomainName, net use uses the current logged on domain.

Specifies the user name with which to log on.

Specifies the fully qualified domain name for the domain where the user account exists.

Stores the provided credentials for reuse.

Specifies the network connection is to use the credentials on a smart card. If multiple smart cards are available, you are asked to specify the credential.

Cancels the specified network connection. If you specify the connection with an asterisk (*), all network connections are canceled.

Controls the use of persistent network connections. The default is the setting used last. Deviceless connections are not persistent. Yes saves all connections as they are made, and restores them at next logon. No does not save the connection being made or subsequent connections. Existing connections are restored at the next logon. Use /delete to remove persistent connections.

Connects a user to the home directory.

Displays help for the specified net command.

Remarks

Connecting and disconnecting from a network resource

Use net use to connect to and disconnect from a network resource, and to view your current connections to network resources. You cannot disconnect from a shared directory if you use it as your current drive or an active process is using it.

Viewing connection information

To view information about a connection, you can do either of the following:

Type net useВ DeviceName to get information about a specific connection.

Type net use to get a list of all the computer’s connections.

Using deviceless connections

Deviceless connections are not persistent.

Connecting to NetWare servers

After you install and run Client Service for NetWare, you can connect to a NetWare server on a Novell network. Use the same syntax that you use to connect to a Windows Networking server, except you must include the volume you to which you want to connect.

Читайте также:  Панель управления серверами для linux

Using quotation marks

If the ServerName that you supply contains spaces, use quotation marks around the text (that is, «ServerВ Name«). If you omit quotation marks, an error message appears.

Examples

To assign the disk-drive device name E: to the Letters shared directory on the \\Financial server, type:

To assign (map) the disk-drive device name M: to the directory User2 within the Letters volume on the \\Financial server, type:

To connect the user identifier User1 as if the connection were made from the Accounts domain, type:

To disconnect from the \\Financial\Public directory, type:

To connect to the resource memos shared on the \\Financial 2 server, type:

To restore the current connections at each logon, regardless of future changes, type:

Команда NET USE подключение сетевого диска

В командной строке NET USE используется для подключения и отключения от общих сетевых ресурсов (дисков) и для вывода сведений о текущих подключениях. Когда команда используется без параметров, выводится список всех подключений данного компьютера. От себя хочу отметить, что команду Net use можно использовать и при работе с Windows 10.

Синтаксис команды NET USE

Для отображения справки для указанной команды net следует ввести команду net help use.

  1. net use [<имя_устройства|*>] [\\имя_компьютера\ресурс[\том]] [<пароль|*>]] [/user:[имя_домена\]] [/user:[имя_домена_с_точкой\]имя_пользователя] [/user: [имя_пользователя@имя_домена_с_точкой] [/savecred] [/smartcard] [>]
  2. net use [имя_устройства [/home[<пароль|*>] [/delete:]]
  3. net use [/persistent:], где
  • Имя_устройства — задает имя ресурса при подключении или имя устройства при отключении. Существует два вида имен устройств: имена для дисковых устройств (то есть, диски с буквенными обозначениями от D: до Z:) и для принтеров (соответственно, от LPT1: до LPT3:). Ввод звездочки (*) вместо имени определенного устройства обеспечит присвоение такому устройству ближайшего доступного имени.
  • \\имя_компьютера\имя_ресурса — указывает имя сервера и общего ресурса. Если параметр «имя_компьютера» содержит пробелы, все имя компьютера от двойной обратной черты (\\) до конца (например, «\\Computer Name\Share Name») должно быть заключено в прямые кавычки («). Имя компьютера может иметь длину от 1 до 15 знаков.
  • \том — задает имя тома системы NetWare. Для подключения к серверам Netware необходимо установить и запустить клиент для сетей NetWare.
  • Пароль — задает пароль, необходимый для подключения к общему ресурсу. Введите звездочку (*) для вывода приглашения на ввод пароля. При вводе с клавиатуры символы пароля не выводятся на экран.
  • /user — задает другое имя пользователя для подключения к общему ресурсу.
  • имя_домена — задает имя другого домена. Пропуск параметра «имя_домена» приводит к тому, что команда net use использует имя домена, заданное при входе в систему.
  • имя_пользователя — указывает имя пользователя для подключения.
  • имя_домена _с_точкой — указывает полное имя домена, в котором присутствует учетная запись пользователя.
  • /savecred — сохраняет введенные учётные данные для дальнейшего использования.
  • /smartcard — указывает необходимость считывания учетных данных со смарт-карты для сетевого подключения. При наличии нескольких смарт-карт появится запрос на указание одной из них.
  • /delete — отменяет указанное сетевое подключение. Если подключение задано с символом звездочки (*), будут отменены все сетевые подключения.
  • /persistent: — управляет постоянными сетевыми подключениями. По умолчанию берется последнее использованное значение. Подключения без устройства не являются постоянными. Выбор значения Yes приводит к сохранению всех существующих соединений и восстановлению их при следующем подключении. При выборе значения No выполняемые и последующие подключения не сохраняются. Существующие подключения восстанавливаются при следующем входе в систему. Для удаления постоянных подключений используется ключ /delete.
  • /home — подключает пользователя к его основному каталогу.

Как видите, синтаксис команды довольно таки длинный, однако следует отметить, что на практике используются не все ее параметры.

Примеры команды NET USE

Таким образом, команда NET USE подключает или отключает компьютер от общего ресурса. Хотя у команды NET USE довольно обширный синтаксис в реальной жизни используются не все ее параметры. Попробуем разобраться в работе этой популярной команды и привести реальные примеры, которые пригодятся в работе.

  • Для вывода сведений о текущих подключениях введите команду net use.
  • Для подключения сетевого диска командой net use с именем диска Z: из общего каталога Public2$ компьютера \\Nuclear следует ввести команду — net use z: \\Nuclear\Public2$
  • Пример net use delete. Для отключения от каталога \\Nuclear\Public2$ подключенного сетевым диском с именем диска Z: служит команда — net use z: /delete
  • Чтобы подключить общую папку Backup$ с компьютера Nuclear под пользователем administrator так, как если бы он подключался из домена Podryad.local, следует ввести — net use d: \\Nuclear\Backup$ /user:Podryad.local\administrator
  • В том случае, если название компьютера состоит из нескольких слов и между ними есть пробелы, то все имя компьютера от двойной обратной черты до конца должно быть заключено в прямые кавычки. Например, для подключения к совместно используемому ресурсу Share1 на сервере «Сервер 1» команда будет иметь вид — net use k: \\»Сервер 1″\Share1
  • Для восстановления текущих подключений при следующих входах в сеть, независимо от будущих изменений, служит команда net use /persistent:yes.

Видео — Работа с NET USE примеры подключения\отключения сетевых дисков

Net Use Command

Net Use command examples, options, switches, and more

The net use command is a Command Prompt command that’s used to connect to, remove, and configure connections to shared resources, like mapped drives and network printers.

It’s one of many net commands like net send, net time, net user, net view, etc.

Net Use Command Availability

This command is available from within the Command Prompt in Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP, as well as in older versions of Windows and in Windows Server operating systems.

Recovery Console, the offline repair utility in Windows XP, also includes the net use command, but it’s not possible to use it within the tool.

The availability of certain command switches and other command syntax may differ from operating system to operating system.

Net Use Command Syntax

This command uses the following general syntax:

net use [<devicename | *>] [\\computername\sharename[\volume] [<password | *>]] [/user:[domainname\]username] [/user:[dotteddomainname\]username] [/user:[username@dotteddomainname] [/home <devicename | *> [<password | *>]] [/persistent:<yes | no>] [/smartcard] [/savecred] [/delete] [/help] [/?]

Review how to read command syntax if you’re not sure how to interpret the net use command syntax as it’s shown above or described in the table below.

Net Use Command Options
Option Explanation
net use Execute the net use command alone to show detailed information about currently mapped drives and devices.
devicename Use this option to specify the drive letter or printer port you want to map the network resource to. For a shared folder on the network, specify a drive letter from D: through Z:, and for a shared printer, LPT1: through LPT3:. Use * instead of specifying devicename to automatically assign the next available drive letter, starting with Z: and moving backward, for a mapped drive.
\\ computername \ sharename This specifies the name of the computer, computername, and the shared resource, sharename, like a shared folder or a shared printer connected to computername. If there are spaces anywhere here, be sure to put the entire path, slashes included, in quotes.
volume Use this option to specify the volume when connecting to a NetWare server. Client Service for NetWare or Gateway Service for Netware must be installed.
password This is the password needed to access the shared resource on computername. You can choose to enter the password during the execution of the net use command by typing * instead of the actual password.
/user Use this net command option to specify a username to connect to the resource with. If you don’t use /user, net use will attempt to connect to the network share or printer with your current username.
domainname Specify a different domain than the one you’re on, assuming you’re on one, with this option. Skip domainname if you’re not on a domain or you want net use to use the one you’re already on.
username Use this option with /user to specify the username to use to connect to the shared resource.
dotteddomainname This option specifies the fully qualified domain name where username exists.
/home This net use command option maps the current user’s home directory to either the devicename drive letter or the next available drive letter with *.
/persistent:< yes | no> Use this option to control the persistence of connections created with the net use command. Choose yes to automatically restore created connections at the next login or choose no to limit the life of this connection to this session. You can shorten this switch to /p if you like.
/smartcard This switch tells the net use command to use the credentials present on the available smart card.
/savecred This option stores the password and user information for use next time you connect in this session or in all future sessions when used with /persistent:yes.
/delete This net use command is used to cancel a network connection. Use /delete with devicename to remove a specified connection or with * to remove all mapped drives and devices. This option can be shortened to /d.
/help Use this option, or the shortened /h, to display detailed help information for the net use command. Using this switch is the same as using the net help command with net use: net help use.
/? The standard help switch also works with the net use command but only displays the command syntax, not any detailed information about the command’s options.

Save the output of the net use command to a file using a redirection operator. If you’re not familiar with this operation, review how to redirect command output to a file for guidance.

Net Use Command Examples

Following are a few different ways you might use this command:

Temporary Mapped Drive

In this example, we used the net use command to connect to the my media shared folder on a computer named server. The my media folder will be mapped to the highest available drive letter [*], which in our example happens to be y:, but we don’t want to continue mapping this drive every time we log onto the computer [/persistent:no].

Permanent Mapped Drive

The above is a slightly more complicated example that you might see in a business setting.

In this net use example, we want to map our e: drive to the smithmark shared folder on usrsvr002. We want to connect as another user account we have [/user] by the name of msmith2 that’s stored on the pdc01 domain with a password of Ue345Ii. We don’t want to map this drive manually every time we start the computer [/p:yes], nor do we want to enter the username and password each time [/savecred].

List All Shared Resources

In this simple example of the net use command, we get a list of all the shared resources currently in use under the user account that’s currently logged in. In our example, the result in Command Prompt shows «Z: \\server\shared folder\» since z: is the drive letter that’s connecting to shared folder on server.

The message «There are no entries in this list.» will show if there aren’t any connections currently set up.

Unmap a Drive

An appropriate final example of net use is the removal [/delete] of a currently mapped drive, in this case, p:.

Оцените статью