1

This is my first time using Post Build Feature of Visual Studio.

I'm just experimenting and I can copy the output file from my project to another project. But, I am not sure how I can copy the file only if a Particular Windows Service is not running. Actually my project consists of a Background windows Service, and I run it before I compile my code, but this background service uses one of DLL's that I use in the Interface application too.

So, how can we check if a particular background service is active? Can we run anything in post build that works on command prompt?

Damon
  • 3,004
  • 7
  • 24
  • 28
Sumit Gupta
  • 2,152
  • 4
  • 29
  • 46
  • 1
    You can use any commands in post build that can be executed from command line, or execute batch file. So, if you know how to do this from command line, you can do this from post-build step. – Alex F Sep 12 '13 at 07:55
  • thanks, just if you know how to check Service is running or not frm command prompt? – Sumit Gupta Sep 12 '13 at 08:05
  • 1
    Well, quick Google search gives this: http://stackoverflow.com/questions/353161/how-to-test-whether-a-service-is-running-from-the-command-line – Alex F Sep 12 '13 at 08:08
  • thanks, I was still searching such thing. – Sumit Gupta Sep 12 '13 at 08:10
  • You can write batch file with one or more parameters (like source file, destination file etc.) and call this file from Post-build step, using Visual Studio macros to fill parameters. Post-build step editing window has Macros button - take a look at it. – Alex F Sep 12 '13 at 08:18
  • Inside batch file, implement all required logic, with running external programs, testing errorlevel, goto etc. I always prefer this way to write non-trivial build actions. – Alex F Sep 12 '13 at 08:19
  • yes reading them, batch files are better option, I did batch files before, just not sure how to use them in Visual studio until now. It is great help now and save my 2 minute on every Build. – Sumit Gupta Sep 12 '13 at 08:21

0 Answers0