If you want to execute a batch file from an UNC Path, windows will first tell you that "CMD does not support UNC paths as current directories" and it will switch to some other directory instead.
If you still want to be able to do your stuff without copying everything to your local drive: use pushd and popd.

pushd will automatically connect the given path as a network drive and popd will disconnect it again.
By using %dp0 as a paramter, you're using the path of the batch file and handing it over to pushd :)

pushd "%~dp0"  
[...]  
popd  

happy scripting :)

Comments