Simplify UNC paths usage in command line batch files
Compatibility : Tested from Windows NT 4 SP6 to Vista
UNC paths don’t work properly in a command line batch file.
I have found a little known command (At least to me). Actually there are two of them.
PUSHD and POPD
Call PUSHD with a UNC share as a single argument and it automatically maps the UNC share to a drive letter. (It starts at Z: and moves backward). So, if we wanted to run a few command line programs within our share we would call it like this:
pushd \\server\share
command1.exe
command2.exe
When you are finished, and want to remove the mapping you call popd. Putting it all together we have this:
pushd \\server\share
command1.exe
command2.exe
popd
Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.