We should use %~dp0 not %CD%

I ran into the following error when I was running some of the setup scripts

Code:
The system cannot find the path specified.

. The problem was that I was running the scripts from the package root, like I usually do. I had already ran some of the scripts correctly before, so I was confused as to why they weren’t working now. After looking through the code I found that our .bat files are all using %CD% to get the current directory, instead of %~dp0.

I believe in the majority of cases, we should be using %~dp0, and referencing any paths from the location of the actual batch file, instead of %CD%, which is the actual current directory of the script’s scope.. so either the location of the directory the script was ran from, or whatever directory the script is now being ran in (i.e. after running cd inside of the script, or in sub scripts..)

I was planning to put a pull request together fixing all of the batch scripts, but I decided I would post here first to make sure that I wasn’t missing anything and to get help with any edge-cases I should be testing for.

You can read more about %cd% vs %~dp0 here http://www.computerhope.com/forum/index….ic=54333.0