Friday, May 15, 2009

Change your working directory

By default whenever you run a batch file, the working directory is usually the directory that contains the batch file.

However, if you drag and drop a file onto the batch file to use the dropped file as an argument, windows uses your user directory as the working directory.

This line below is probably the most awesome line to use at the start of a batch file to make the working directory point to the directory that contains the batch file no matter where it starts.

cd /d %~dp0

No comments: