Previous Posts


Create a date and time stamp in your batch files

Verify Install of Windows Daylight Saving Patch

Windows 98, ME DST Patch

New vulnerability discovered in Excel

Active Sync Released For Vista

The many faces of Windows

Tweak your IE 7 Settings

The 5 sins of Vista

Disable USB Flash Drives

Reduce Word 2007 Compatibility Problems



Archives

May 2005

January 2006

April 2006

May 2006

June 2006

July 2006

September 2006

October 2006

November 2006

December 2006

January 2007

February 2007

March 2007

April 2007

May 2007

June 2007

July 2007

August 2007

September 2007

October 2007

November 2007

December 2007

January 2008

February 2008

March 2008

April 2008

May 2008



Subscribe to our Feed:






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


Command Line UNC POPD



I have tested this with Windows NT 4 SP6, and it works all the way through Vista...so you are safe using it on any of these versions of Windows.


Posted By: Steve Wiseman on Sunday, February 18, 2007

Check out our utilities for windows

 



Copyright © IntelliAdmin, LLC, 2008. All Rights Reserved