4

I would execute an exe file or a bat file after that the compilation of a C++ program ends. How could I do this?

EDIT 1 This is my actual command line:

start "C:\mypath\myexe.exe myarguments"
Stefano
  • 3,213
  • 9
  • 60
  • 101

2 Answers2

3

Check out the "Build Events" section in your C++ project's configuration properties. Here you can define commands to run before the project builds, before the linker runs, and after the project has built.

Peter Huene
  • 5,758
  • 2
  • 34
  • 35
  • The "Command Line" property gets written to a batch file and executed. You would execute the .exe as if you would from a batch file you authored yourself. Note that if you don't specify a full path to your executable, the .exe must lie on the PATH environment variable or in the "Executable Directories" property in the "VC++ Directories" settings. – Peter Huene Feb 27 '11 at 10:38
  • @Peter wait, so I should create a bat file that starts my exe file or should I use the same commands that I would use in the bat file but inside the command line property of VS? – Stefano Feb 27 '11 at 10:51
  • Also, if you click the dropdown arrow on the property and select "Edit...", this will bring up a multi-line edit dialog. Makes entering in the contents a bit easier. – Peter Huene Feb 27 '11 at 10:56
  • @Peter I've edited my answer with my actual command line, it doesn't work. It starts a console window but does nothing :-( – Stefano Feb 27 '11 at 10:58
  • Are you using "start" so that the post-build event doesn't wait for your .exe to terminate? The console window popping up is the result of using start, to be sure. By "does nothing", what do you mean exactly? Does the popped up console show nothing? – Peter Huene Feb 27 '11 at 11:01
  • @Peter The console shows nothing and the exe isn't executed. What I would do is wait that all the projects in the solution are compiled correctly and after I would start doxygen to generate the documentation – Stefano Feb 27 '11 at 11:06
  • I suspect something is wrong with the way you're doing start, such as passing it one argument instead of the expected two. Try: start "c:\mypath\myexe.exe" "arguments". – Peter Huene Feb 27 '11 at 11:13
  • @Peter nothing, it gives an error on arguments because it seems to think that "arguments" is the file to execute – Stefano Feb 27 '11 at 11:19
  • Actually, start may not like the full path. This utility's conventions / error handling defy my logic. – Peter Huene Feb 27 '11 at 11:19
0

Check Post Build Event command line, in the Project properties.

Anuraj
  • 18,859
  • 7
  • 53
  • 79