How to find full patch of script from within the script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Joseph
Posts: 2
Joined: 13 Feb 2013 13:44

How to find full patch of script from within the script

#1 Post by Joseph » 13 Feb 2013 15:15

Dear Team Members,
Do you know of any variable or procedure to find the full directory Path of a script from within the script when is is run?

For example, If the script is called "C:\Program Files\dir1\dir2\joseph.bat"
the full directory would be called "C:\Program Files\dir1\dir2\"

Can the called script derive its full directory path?

Thanks
Joe

shirulkar
Posts: 40
Joined: 15 Jan 2013 23:53

Re: How to find full patch of script from within the script

#2 Post by shirulkar » 13 Feb 2013 15:25

echo "%~dp0"

Joseph
Posts: 2
Joined: 13 Feb 2013 13:44

Re: How to find full patch of script from within the script

#3 Post by Joseph » 13 Feb 2013 15:37

Shirulkar,

Thank you for the answer. I can use the command
set root_dir=%~dp0
from within a dos script to obtain the full directory path of script.

Post Reply