How to run an exe on a post build event

Provided answer is correct, however providing the full path is not always necessary.

Example: run one of the projects output executable.

  • (optionally) Configure post-build event to run Always
  • use a path relative to the project path. E.g.: "$(ProjectDir)bin\Debug\maybe_just_refreshed.exe" or better version suggested by m93a: "$(TargetDir)maybe_just_refreshed.exe" (this compansates for the cases when output location is customized (not the default bin\Debug).

None of these answers worked for me.

Even though my exe was at the file path I provided, it still exited with a code of "whatever" and never worked.

Then I did this:

cd $(ProjectDir)

"MyProgram.exe"

...both on separate lines in the post build event command line editor.

My app is located in the project directory. They didn't work on the same line, but separate lines worked fine.


Just as you would run this .exe from command-line. So, specify your .exe with full path and enclose it in double-quotes if either path or executable name contain spaces.