How to Map Network Drive in Batch Script
- Map Network Drive in Batch Script
-
Map Network Drive Using
net use
Only -
Map Network Drive Using
net use
With Username and Password -
Map Network Drive Using
net use
With Automation
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.
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