MichaelS
MichaelS

Reputation: 7123

How to run an exe on a post build event

What is the correct script to run a certain exe file on a post build event?

Upvotes: 21

Views: 35269

Answers (3)

Barry Franklin
Barry Franklin

Reputation: 1820

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.

Upvotes: 3

Alexei - check Codidact
Alexei - check Codidact

Reputation: 23108

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).

Upvotes: 12

Sergii Kudriavtsev
Sergii Kudriavtsev

Reputation: 10532

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.

Upvotes: 28

Related Questions