Determining current directory where batch file executes

When a batch procedure executes, I initially set the working directory to the current directory where the batch procedure executes.  This is done by executing the command:

cd /d %~dp0

The explanation of the syntax:

%0 name of batch file
~dp returns drive and patch of specified argument
cd /d Change directory. Use of the /d switch changes current drive
Advertisements

One Response to Determining current directory where batch file executes

  1. link submission…

    […]Determining current directory where batch file executes « Jim Lahman's Weblog[…]…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: