Skip to main content
GameDev.net gamedev.net
🔒 Locked

Launch another program before debugging in VS?

Started by skyfire360 Apr 6, 2009 at 6:23 PM 2 replies 950+ views
Original Post
skyfire360
skyfire360
Quick question, since I can't seem to find any resources on this: Is it possible to automatically launch another program/batch file when I debug the "start up" project in Visual Studio? I'm writing a client program, and every time it starts up it connects to a server program. Currently, I have to run the server program by hand (via a batch file) before starting the VS debugger. Is there a way to have VS auto-start a batch before it starts and attaches to the startup project? I rooted around in the project properties->debugging screen, but didn't really find anything along those lines.
I do real things with imaginary numbers
mutex
mutex
I'm not aware of any way to do that within Visual Studio. But you can always add a special command-line option to the client that starts the server.

frob
frob
There are a few options.

In your project properties, on the "Build Events" page, add your batch file as a post-build event program. It will execute those programs after your project successfully builds.

Another option is to modify the "Debug" page, change it to start an external program rather than the project. Your external program should be the batch file that runs your server and then runs your client program.

Your client can have a command line option to forcefully start the server if it doesn't detect one.

If you have more complex needs, you could write a small Visual Stduio plugin. The free DXCore plugin library from DevExpress makes writing your own simple plugins in C# or other languages extremely simple.

If your needs are even more complex than that, you can write a program that sits on the side, watching for your program to show up on the processes list. When your program is run, it can do whatever external magic you need.

I'm sure a creative person could come up with many other ways to do this.
janta
janta
Quote:
Original post by frob
Another option is to modify the "Debug" page, change it to start an external program rather than the project. Your external program should be the batch file that runs your server and then runs your client program.

I don't think you can do that. I think the debugger needs to attach to the target program and so a batch file will not work.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.