How can you get the directory of the script that was run and use it within the .cmd file?
+4
A:
Raymond Chen has a few ideas:
http://blogs.msdn.com/oldnewthing/archive/2005/01/28/362565.aspx
Also the comments in the article are well worth scanning.
Update: For the benefit of ketorin and others who didn't read the comments in the article:
http://blogs.msdn.com/oldnewthing/archive/2005/01/28/362565.aspx#362741
This covers the use of %~dp0.
Kev
2008-09-24 21:34:20
This does not answer the question. %CD% gives the current directory, while what was asked was the directory of the script.
ketorin
2008-10-07 11:58:49
**@ketorin:** This **DOES** answer the question. %CD% will change if the script itself change directory throughout it's usage (pushd/cd/..) but **%~dp0** will **NOT** change and always point to where the script is located.
Jay
2009-09-08 17:18:37
+6
A:
This is equivalent to the path of the script:
%~dp0
Here's a webpage with more resources on this sort of thing: http://www.ss64.com/ntsyntax/parameters.html
Landon
2008-09-24 21:38:33