Page 1 of 1

How to find full patch of script from within the script

Posted: 13 Feb 2013 15:15
by Joseph
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

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

Posted: 13 Feb 2013 15:25
by shirulkar
echo "%~dp0"

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

Posted: 13 Feb 2013 15:37
by Joseph
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.