Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Map Network Drive cmd (batch file) – net use user password

This article will focus to another way to Map Network drive on your computer instead from explorer interface method. You will learn to map network drive using cmd (command line) along with “net use” where you can include also user password. Not only but article with explain also how to create batch file to map network drive and to automate this process on your computer or in the all network.

Map Network Drive Command Line

How to map network drive using cmd commands “net use”

You can map a network drive from different ways but the cmd is like a “professional” way. The universal command for the windows operating system to map network drive from cmd is “net use”. To map a network drive using T as the drive letter and without username password protected, use the following guide:

  1. Connect to command prompt by clicking on start and search for cmd.
  2. Right click and open as “Run as administrator”.
  3. Copy paste the below command and click Enter:
net use T: \\networkShare\Test

Note! Check the file explorer and the Map Drive “T” will appear there.

Map network drive cmd

Net use with username and password

The above command will work and completes successfully without asking the user to provide username/password if user has authorized access to this network share. But if not? Is simple, you will need to use username and password on the prompt that will appear. Keep remember that the user need to have access to the share.  But the easy way on is to use “net use” command on the command prompt line explained above.

  1. Open again the command prompt with “Run as administrator”
  2. Edit the command below with you username password
  3. Copy paste in to CMD and click Enter:
net use T: \\networkShare\Test /u:domainname\username password

Tip! Use “*” instead of letter so in this way the system will use automatically an unused drive letter.

Most of the people now days like to avoid plain text and for this you can specify only the username. The command prompt will ask you for the password.

net use T: \\networkShare\Test /u:domainname\username

net use – username password

Batch file to map network drive with username and password

What if you need to automate the creation of network drive? The batch file comes to help you in this situation where you can schedule that or to configure on GPO. In this way you war automate the creation of network drive on your network devices. Let’s check how to create a batch file to map network drive with username and password:

  1. Open a notepad file
  2. Type @echo Create new T: drive mapping
  3. Type “net use T: \\networkShare\Test path /persistent:yes”
  4. Type :exit
  5. Save the file as name.bat file
  6. Automate this bate file with your automation tools.
  7. Check this post to automate it on task scheduler
@echo Create new T: drive mapping

net use T: \\networkShare\Test path /persistent:yes

:exit

Tip! If you want to map multiple drive just keep repeating step 2 and 3. Change the later and the path if it is different.

Tip!! Use “/u:domainname\username password” commnad in the script to include username password.

Map system drive (C:)  of remote computer

What if you need to map a drive form an computer on the network that you have administrator access? Yes is simply easy just you need to change a part of net use command:

net use T: \\testpc\D$ /u:username password

Net use persistent

Mapped drives are not persistent by default and to do that you need to use some cmd commands. By default if we use the command above to map drive the mapped drive would disappear after you restarted the computer. So make them persistent by using the /persistent switch.

/persistent:Yes: The connection that you’re currently creating will be persistent. Also the future connections during the same session will be also persistent. So you don’t need to keep using the /persistent:Yes commnad until you use the /persistent:No switch to turn it off.

/persistent:No: Turns off the persistency toggle. Future connections will not be persistent until you turn the toggle back on.

net use T: \\networkShare\Test /u:domainname\username password /persistent:yes

net use persistent

Map a network drive using PowerShell

A relevant automation as CMD is also the PowerShell. The PowerShell commands differ from cmd commands so below we will explain the equivalent command:

New-PSDrive -Name T -PSProvider FileSystem -Root “\\networkShare\Test” -Credential user\domain –Persist

-Name – Write the desired drive letter you want to assign. In the example is assigned ‘T’.

-Credential – Is equivalent to checking the ‘connect using different credentials’ option. If you skip this option you won’t get the prompt asking for the username and password.

–Persist – equivalent to checking the ‘Reconnect at sign-in’ in the explorer.

To find the domain open system properties. The name after the full computer name is a domain name in the network.

map network drive powershell

Mapping a network drive for all users

What if you have multiple users on the PC and you need to create automatically the certain map drive for all users? In this case the below solution will help you.

  1. Open a notepad file
  2. Type @echo Delete T: drive if exist
  3. Type net use T: /delete
  4. Type @echo Create T: drive
  5. Type net use T: \\networkShare\Test ” /u:domainname\username password
  6. Type :exit
  7. Save the file as AutoMapDrive.bat file
  8. Copy the bat file to “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp”
  9. Every time the PC starts, will map remote directory on to this computer for all the users that login to it.
net use T: /delete

net use T: \\networkShare\Test " /u:domainname\username password

Conclusions

This is all about Map Network Drive using cmd and batch file with help of net use user password commands. Let’s hope that our solutions help you to automate everyday jobs.

The post Map Network Drive cmd (batch file) – net use user password appeared first on Get IT Solutions.



This post first appeared on Get It Solutions, please read the originial post: here

Share the post

Map Network Drive cmd (batch file) – net use user password

×

Subscribe to Get It Solutions

Get updates delivered right to your inbox!

Thank you for your subscription

×