Net use commands windows

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.

Читайте также:  Удалить пользователя windows 10 microsoft

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 примеры подключения\отключения сетевых дисков

Как подключить сетевой диск из командной строки Windows?

Подключить сетевой диск к расшаренной папке из графического интерфейса Windows не составит труда. Достаточно воспользоваться проводником Windows, чтобы найти нужную папку и в главной кладке найти кнопки Подключить как диск. Но если Вы уже знаете сетевой путь для подключаемой папки, то Вы сможете еще быстрее подключить сетевой диск с помощью командной строки.

Использование сетевого ресурса как диска, означает присваивание этому ресурсу буквы диска для того, чтобы с ним было легче работать. Мы будем использовать команду net use в командной строке для подключения сетевого диска. Вы также можете использовать ту же команду и в PowerShell, если хотите.

Общий синтаксис команды, чтобы создать сетевой диск, следующий:

, где drive — это буква диска, которую Вы хотите присвоить, и path — это полный путь к общей папке. Так, например, если бы мы хотели сопоставить букву диска Z с разделом \\userello-pc\film, мы бы использовали следующую команду:

Если ресурс, к которому Вы пытаетесь подключиться, защищен с помощью аутентификации и Вы не хотите вводить учетные данные каждый раз при открытии сетевого диска, можете добавить имя пользователя и пароль в команде с помощью параметра /user: password. Например, подключим тот же самый ресурс \\userello-pc\film, но при этом добавить аутентификацию пользователя с логином и паролем. Для этого используем команду:

По умолчанию подключенные сетевые диски не являются постоянными. Если мы подключаем диски с помощью команд, перечисленных выше, подключенные диски исчезнут при первой перезапуске компьютера. Если необходимо недопустить этого, необходимо сделать подключение дисков постоянным. Для этого служит параметр /persistent, который принимает два значения: yes и no.

  • /persistent:yes — создает соединение, которое позволит в течении этого же сеанса работы создавать постоянные подключения дисков. То есть, если Вам понадобится подключить не один диск и все они должны быть подключены всякий раз при загрузке компьютера, достаточно использовать параметр /persistent:yes.
  • /persistent:no — делает с точностью наоборот отключает возможность создания для этого и следующих за ним подключения в течении этого сеанса работы.

Если Вам следом надобится подключить ещё пару-тройку сетевых дисков, то /persistent:yes можно не добавлять. Все диски итак будут подключены постоянно, даже после перезагрузки компьютера.

Если понадобится удалить подключенный сетевой диск, то это можно сделать просто указав удаляемую букву диска и добавив параметр /delete. Например, следующая команда удалит сопоставление диска, которые мы назначили для диска Z:

Вы также можете использовать звездочку в качестве подстановочного знака, если требуется удалить сразу все подключенные сетевые диски

Вот такая не сложная инструкция позволит Вам с легкость использовать командную строку, чтобы не менее эффективно, чем используя Проводник, подключить сетевые диски и удалять их.

How To Use Net Use Command In Windows Command Line?

Windows operating systems provide the net use command in order to connect ,remove, configure connections to the shared resources like mapped drives, network resources and network printers. net use command is used from command line and provided operating systems Windows XP, Windows 7, Windows 8, windows 10 and Windows Servers from 2003 to 2019 .

Syntax

net use command has following usage syntax. We will provide the drive name and the path we want to use.

  • `DRIVE:` is the name of the drive like `:G` `:Z` etc. used with local system.
  • `PATH` is the remote resource we want to use which will provide the IP address or hostname with resource URI. Example \\192.168.1.20\test

We can get some help about net use command by using /? parameters like below.

net use Help

List Currently Existing Shares

We will start by listing currently existing, joined or mounted remote shares. We will just use net use command like below.

List Currently Existing Shares

Join or Mount A Remote File Share

We will start with a simple example by mounting a remote file share into our local system. We will mount file share named Backup which resides at 192.168.145.162

Join or Mount A Remote File Share

Join File Share with Specified User

In previous example we have mounted remote file share with the current user and privileges. In some cases we may need to mount with a different user than current session user. We can specify the user we want to use with /USER option. In this example we will use user Administrator .

Join File Share with Specified User

There will also also some information about the mount like Status, Connections, Resource type.

OR we can also provide the user password explicitly. Keep in mind that providing password in clear text is a security problem. Password will be 123456Aa.

Join File Share Persistently

Mounting or joining remote file shares will have only effect current sessions. If session is closed or system is restarted or connection is lost the share will not mounted automatically. This is the default behavior. We can also join or mount a remote file share persistently with the /persistent:Yes .

Join File Share Persistently

Join File Share and Specify Drive Letter

Up to now we have not specified a local drive letter to the mounted or joined remote share. The default behavior is providing a drive letter in a row manner. We can specify the drive letter like :W or :Z like below.

Make All Future Connections Persistent

The default behavior of the net use command is making connections not persistent. If we want to make all future connection persistent without specifying persistent option explicitly we need to enable persistence globally like below.

Join Printer Share

Printers also a remote resource which can be used by multiple computers like file shares. We can use net use command in order to join a printer into local system. We just provide the printer IP address or host name.

Disconnect From A File or Printer Share

If we want to remove, delete or disconnect from all ready connected share we can use /delete option. We also need to specify the share letter we want to remove. In this example we will remote share named :z like below.

Disconnect and Close All Shares

We may need to removei close and disconnect all currently mounted shares. We will use * with the /delete like below.

Disconnect and Close All Shares

There is a confirmation mechanism which will ask us that whether we want to continue removal of the remote shares.

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