Service starts - then stops

kazmax

Member
Joined
Sep 24, 2005
Messages
8
Programming Experience
10+
I managed to write and install a small Windows service using VB.NET this afternoon (VB.NET 2005). It took a little bit of experimentation to get it installed using InstallUtil but I got there in the end.

However, when I start the service from the command line (NET START ...), it returns zero. If I start it from the SCM it starts and then immediately stops. There is a helpful popup dialog with the SCM which suggests that some Windows services start and then stop because they have nothing to do. I'm a bit confused by this because I thought services spent most of their time sitting waiting for an event to trigger them.

The service I have written creates a timer which is supposed to fire every 60 seconds. But the service comes up, starts the timer, then closes down immediately.

Can anyone suggest how I am supposed to make this service stay up?
 
I forgot to set the service up to logon to the local system account.

In the services dialog right-click on the service name, select properties. On the Logon tab make sure the radiobutton for logging onto the local system account is checked.

Might not be the same problem for you, but as soon as I defined the logon account properly I was in business and it now works very reliably.

I forget the details now, but you can set this up in the project so that each time you install the service it knows immediately to logon to the system account - you don't have to go thru this rigmarole.

Hope this helps!

Andrew
 
Back
Top