My Stuff

My Collection of Useful Stuff

« PreviousNext »

IntelliAdmin.com: Simplify UNC usage in command line batch files

25 February 2007

IntelliAdmin.com: Simplify UNC usage in command line batch files
Simplify UNC usage in command line batch files
Many times a UNC path does not work properly in a command line bat file. This is a hold over from DOS, a compromise to ensure backward compatibility.

Command Line UNC

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

Command Line UNC PUSHD

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

Posted in Windows | Trackback | del.icio.us | Top Of Page

Comments are closed.