1

When I press ctrl + F5 or F5 in VC++ I need to first execute a script that setups the environment such as cmd variables etc and then execute my C++ application.

Is is possible to execute such bat file before execution/debugging, not before/after compilation/linkiage.

Anton Andreev
  • 2,052
  • 1
  • 22
  • 23

1 Answers1

2

In the debugging section of your project properties you can set the command which is executed. You are free to define here what to execute. Set the path to your batch file and start your application from your batch file. You can even add arguments that are passed to your batch file.

mkaes
  • 13,781
  • 10
  • 52
  • 72
  • 1
    +1 It works for CTLR + F5. The problem is that I would also want to work for F5. Now it does not because cmd files of course can not be debugged. This gets us back to where I started - execute a script, but if possible do not change the name of the executable. I also updated my question. – Anton Andreev Jan 29 '12 at 12:58
  • 1
    @Anton: That makes it of course very difficult. The question is can you set up the environment before you start VSTS? That would be one way. There is also the possibilities to specify an environment in the debugging section. But I never did this. So I cannot tell if it helps. – mkaes Jan 30 '12 at 09:16
  • 1
    Validated that variables can be set in Properties-> Debugging -> Environment. Do not use the word "set", just "ROOTDIR=c:\" as it is the output from the DOS command "set". – Anton Andreev Feb 10 '12 at 13:46
  • I have the same question but I need to copy files not just set environment variables. What should I do? – Ben L Nov 04 '13 at 20:10
  • @BenL: Why don't you copy your files as a post build step? – mkaes Nov 05 '13 at 09:15
  • @AntonAndreev My reason for copying the files is only to make a lightweight deployment mechanism for internal testing and debugging. I've always done it as a "post-build step" but it's frustrating since this system is usually specific to this machine and only used in the debugging mode. Also, forcing the post-build to run again is a pain, removing it from the release build is a pain. (I'm often writing plugins for applications) – Ben L Nov 05 '13 at 21:44