How can I get the path to the batch file being run?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
cmcconn
Posts: 1
Joined: 18 Jun 2008 16:16
Location: San Jose, CA

How can I get the path to the batch file being run?

#1 Post by cmcconn » 18 Jun 2008 16:19

I have a batch file in my %PATH%. When I run it I need to get it's path so I can open a file that lives in the same folder. I was hoping some sort of built-in variable exists but can't find anything like that. Any ideas would be appreciated.

- Chris

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

#2 Post by jeb » 19 Jun 2008 00:08

Hi Chris,

this should work

Code: Select all

echo path to %0 is %~dp0


jeb

Post Reply