If you have ever tried working with UNC paths with the CMD either at the console or using a batch file you likely have run into a problem like this:
Luckily there are a couple useful commands to overcome this limitation. The commands are “pushd” and “popd”.
‘Pushd’ used with a UNC path will mount the path as a network drive and automatically save the network drive to it’s working directory.
Pushd has mapped our network path to the first available drive letter ‘X’ and automatically changed our working directory.
We can now run commands against our network location.
We created and then listed a folder on our network location.
To disconnect the share we can simply use the ‘popd’ command.
Our mapped network location is now disconnected.
This is how it may look in a batch file.