How to Map Network Drive in Batch Script

MD Aminul Islam Feb 02, 2024
  1. Map Network Drive in Batch Script
  2. Map Network Drive Using net use Only
  3. Map Network Drive Using net use With Username and Password
  4. Map Network Drive Using net use With Automation
How to Map Network Drive in Batch Script

This article will discuss how we can map a network drive in Batch Script.

Map Network Drive in Batch Script

We will see three formats of the same command for this purpose. But, the general format of the command is:

net use P: "\\server\folder\file"

You can choose any one of them based on your need.

Map Network Drive Using net use Only

Using only net use, you need not provide any username or password. The general format for this is the same as the one mentioned above.

For example,

net use T: \\NetShare\Test

Map Network Drive Using net use With Username and Password

You need to provide a username and password with the command in this format. For example,

net use T: \\NetShare\Test /u:domain\username password

Map Network Drive Using net use With Automation

If you are looking for a format that will automate the connection, you should follow this command. For example,

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

Here, /persistent:yes is a flag that provides an automated connection to share on logon.

As you can notice, we used T as the network driver mapping variable here.

All of the methods discussed above are only for Windows CMD.

MD Aminul Islam avatar MD Aminul Islam avatar

Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.

LinkedIn

Related Article - Batch Script