Get IT Solutions

How to do IT
Menu
  • Home
  • SCCM 2012
    • Deploy Packages
    • Troubleshooting errors SCCM 2012
  • Windows
    • Applications Silent Install
    • Windows Tools
    • Windows Error
    • Script
    • Exchange Server
    • Troubleshooting Office
    • Applications Errors
  • Database
    • SQL Server
    • MySQL
    • Oracle
  • Cybersecurity
  • Other
  • Reviews

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

This article will focus on another way to map a network drive on your computer instead of from the 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 an article with explain also how to create a batch file to map network drive and to automate this process on your computer or in the all network.

Read Also: Unmap network drive using cmd

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 a 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

Map network drive cmd

Net use with username and password

The above command will work and completes successfully without asking the user to provide a username/password if the 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 remembering that the user needs to have access to the share.  But the easy way is to use the “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 into CMD and click Enter:
net use T: \\networkShare\Test /u:domainname\username password

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

 

Most 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

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
READ ALSO -   Forfiles script to delete files older than 7 days - Command Line

 

@echo Create new T: drive mapping

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

:exit

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

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

Map system drive (C:)  of remote computer

What if you need to map a drive form a computer on the network that you have administrator access? Yes is simply easy just you need to change a part of the 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, future connections during the same session will be also persistent. So you don’t need to keep using the /persistent: Yes command 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

net use persistent

Map a network drive using PowerShell

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

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 a 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 the remote directory onto 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.

Share
Tweet
Google+
Pinterest
Linkedin
Stumble
Email
Prev Article
Next Article

Related Articles

How to rename folder in CMD (Command Line)
In this article, we will show you how some quick …

How to rename folder in CMD (Command Line)

How to add registry key & values with command line (CMD) _ PowerShell _ Batch
In this part, we will cover how to add registry …

How to add registry key & values with CMD | PowerShell | Batch

Best Computers & Laptops

Best Computer for Cyber Security – Laptop and Desktop
Best Computer for Cyber Security
Hey, are you seeking the best computer for cyber security? Well, we must say you have come to the right place to find your answer and guidance. There are a plethora of products out there for you to pick from ...
Read More
Best Computer for Microsoft Office & Excel – Laptop and Desktop
Best Computer for Microsoft Office & Excel
Are you finding the Best Computer for Microsoft Office and Excel? In modern days, the best laptop or desktop set is the one which is both portable, has good looks and offers the smoothest performance. Microsoft Office is a package ...
Read More
Best Computer for Hacking – Laptop and Desktop Selection
Best computer for Hacking
When it comes to hacking, either laptop or desktop, choosing the best computer for hacking would be an exhilarating job. There are many specifications to be considered for hacking ...
Read More

SQL Server Tips

FIX sqlstate 42000 – mysql error 1064 – you have an error in your sql syntax
Sqlstate 42000 Is a general code that come together with other number. Most often comes with the code 1064 and ...
Read More
The execute permission was denied on the object – SQL Server Error
The execute permission was denied on the object
The following article will handle “the execute permission was denied on the object” error appears on SQL Server. This error ...
Read More
How to Read Data from LDF file in SQL Server – A Complete Guide
Read LDF File
Hello Everyone, Today we are going to address the most popular query of SQL users, how to read data from ...
Read More

Search

We are on:

Get FREE SPACE for your PC

3 Method to Delete Temp Files in Windows 7/10 including vbs script

In this post we will explain how to delete temp files windows 7 using three different methods including vbs script ...
Read More

Fastest way to delete hiberfil sys from windows 10/8/7 and XP – CMD

In this article we will explain how to remove or delete hiberfil sys from Windows 10/8/7 and XP . If you does ...
Read More

Learn How to Silent Install Applications

Silent Install Adobe Flash Player
In this tutorial will explain how to silent install adobe flash player 25, Msi and Exe version. How to disable auto update and uninstall older ...
Read More
Java Silent Install and Uninstall Older Version – Deploy Package MSI
This tutorial will explain how to silent install Java MSI/EXE version and disable auto-update. The command line will also uninstall the ...
Read More
Silent Install Adobe Shockwave Player 12 and disable update
In this tutorial will explain how to silent install Adobe Shockwave Player 12 msi and disable auto update. The command will uninstall older ...
Read More
Silent Install Google Chrome MSI, Silent Uninstall and Disable Auto Update
This tutorial will explain how to silent install Google Chrome MSI and disable auto update. The command will uninstall older version of ...
Read More
Silent Install Adobe Reader 11 and DC – msi and exe – disable update
In this tutorial will explain how to silent install Adobe Reader version 11 and DC. We will user both version "msi" ...
Read More
Silent Install Mozilla Firefox msi and exe file – Including Silent Uninstallation
This tutorial will explain how to silent install Mozilla Firefox. We will use MSI and EXE files to perform a silent ...
Read More
Skype Silent Install Msi and disable updates
In this tutorial will explain how to silent install skype  and disable auto update. The command will uninstall older version of Skype and ...
Read More
Filezilla Silent Install msi and exe version
Filezilla silent install tutorial will explain how to perform a silent installation of application. We will explain methods, silent install ...
Read More
Silent install VLC Media Player
In this tutorial will explain how to silent install VLC Media Player. We will explain both methods for exe and ...
Read More
Notepad++ silent install exe and msi version – Command Line
Notepad++ silent install is the new article from a series of silent installations. Notepad++ as free software has two main ...
Read More

Batch File Solutions

How to list files in cmd – Command Prompt – Windows 10
Whenever you want to search and make a list of all files on a specific folder, you used the windows ...
Read More
Batch rename multiple files in folder – CMD script – Bulk Method – Win 10
The following article will teach how to rename multiple files in a folder with the bulk method using Command Line ...
Read More
Batch script rename file using Command Line (CMD) & PowerShell – Windows 10
The following article will use the “rename” or “ren” command to rename the file using a command prompt. Also, we ...
Read More
Change extension of multiple files at once – CMD batch file
The following article will teach the methods to change the extension of multiple files at once using command prompt and ...
Read More
How to delete registry key with command line | PowerShell | Batch
The following article is the third of series about registry and working on it through command line (CMD) and PowerShell ...
Read More
How to add registry key & values with CMD | PowerShell | Batch
The registry is the place where most of the applications store the settings but not only. Used also from the ...
Read More
Unmap Network Drive CMD – (Batch file) – net use delete command
After we posted the methods to map network drive using cmd commands we come this time with the method to ...
Read More
Map Network Drive cmd (batch file) – net use user password
This article will focus on another way to map a network drive on your computer instead of from the explorer ...
Read More
How to Find Large Files on Windows 7 & 10 – CMD Forfiles Command
If the capacity of your hard drive is running low, it is time to clean off some files and to ...
Read More
CMD Script to check disk space on windows and multiple remote servers
The following article will provide you script to check disk space. The Script monitor space on windows and multiple remote ...
Read More

Get IT Solutions

How to do IT

About Us

Get IT Solutions is a personal blog, which is managed to guide people for various topic.

Second Menu

  • Donate
  • About Us
  • Contact Us
  • Privacy Policy

What Will You Find

Automation is our area of writing where are included scripts, batch and various tips to automate your daily job.
Copyright © 2025 Get IT Solutions