0

If I run a .cmd script (powershell) in windows from a different folder, (which may be relative, and the .cmd script might be relative to this) I don't know what folder the .cmd script is running in. This happens in the post build step of visual studio. The cmd script might perform operations on the current folder, which might not be it's source folder, thus an error. Its own source folder might be different than the folder it's being called from. I need a variable that gives it's own folder, not the 'current' folder, or perhaps just to set it's own source folder as current.

The post-build step in visual-studio can run a .cmd script in a relative folder, and the cmd script runs in the visual studio's project folder.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Todd
  • 97
  • 1
  • 6
  • 1
    Use `%~dp0` to reference the cmd files location and/or cd/pushd there. –  Apr 09 '19 at 16:06
  • Possible duplicate of [How to get windows batch's parent folder](https://stackoverflow.com/q/16623780) and [Batch file: get absolute path of parent directory](https://stackoverflow.com/q/33119361) – aschipfl Apr 09 '19 at 17:58

0 Answers0