Windows Service question

  • Thread starter Thread starter Yoavo
  • Start date Start date
Y

Yoavo

Hi,
I wrote a windows service using c#.
Is there a way to start the service automatically after it has been
installed ?

Yoav.
 
AS far as i know there is no way to make the installer do this for you. You
would need to build a small exe and set it up as a custom action. It could
easily start "net start" commands to do the work.
 
Hi,

| Hi,
| I wrote a windows service using c#.
| Is there a way to start the service automatically after it has been
| installed ?

Of course, one of the property of the ServiceInstaller class is StartType.
Just select Automatic
 
Hi,

message | AS far as i know there is no way to make the installer do this for you.
You
| would need to build a small exe and set it up as a custom action. It could
| easily start "net start" commands to do the work.

Opps :(
I miss readed the OP's post. you are right there is no way of doing this
except your described way.
 
Well, actually there is.
The ServiceProcessInstall class publishes an event called AfterInstall that
will be fired after the service is installed.
If you add code on that event to run a piece of code you can start the
service, via net start or via ServiceController.Start.
 
I'm not sure that StartType =Automatic will actually start the service
immediately after the install, more likely the next time the machine boots.
Laura's solution is good, and there is also an enhanced installer produced by
somebody in an article on Codeproject.com that offers this and additional
options.
Peter
 
Back
Top