rd42
rd42

Reputation: 3594

C# Windows Service Starting and stopping

Just trying to save some clicking and typing while I create a service. Right now the steps are:

  1. cmd prompt net stop service name
  2. compile service
  3. cmd prompt net start service name

I'm sure there is a better way to do this, anybody here know of one?

Thank you.

Upvotes: 1

Views: 668

Answers (3)

3Dave
3Dave

Reputation: 29071

When creating services, I embed the service class in a console app and add some interactive code to run the service's .run method and stop/start, etc. This makes it MUCH easier to test and debug.

Upvotes: 1

Paul Creasey
Paul Creasey

Reputation: 28894

Right click the project > properties > build events tab

You can use the pre-build and post build events to do steps 1 and 3 respectively.

Upvotes: 0

Tim Lloyd
Tim Lloyd

Reputation: 38494

You can configure steps 1 & 3 as pre and post build events for the project. Step 1 will be executed before compiling, and step 3 will execute after a successful build. This should automate things nicely.

Upvotes: 2

Related Questions