Mapping a network drive on windows is very easy using UI tools. It goes this way…
- Open Windows explorer
- Go to Tools – Map Network Drive
- On new window select a letter as Mapped Network Drive (e.g. P: )
- Select a network folder by browsing or just paste network path (e.g. \\hostname\FolderName) and click on Finish
Now you can see a new Drive in your explorer. But what if you want map a drive through a batch script? Yeah, you need to know a command to map network drive from command line. It goes this way.
To map a network drive from command line you need 2 inputs same as above.
- Drive Name (e.g. P: )
- Network Path (e.g. \\hostname\FolderName)
Now follow the steps below
- Go to run and type cmd
- On command line enter the following command
- subst \\hostname\FolderName P:
This will map your network drive. Now to make sure that you have mapped it correctly, type drive name and hit enter. E.g. P: hit enter. Now user dir command to list all directories and files. You can also go to explorer and check that new drive is available.
– Ashish Kulkarni