Auto start service after (or during) setup

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a windows service and added a installer for the service.

The service is set to autostart. After installation the service is listed in
services as autostart. This is all fine, but I also want to start the service
after or during installation.

How can I start the service in my setup? (using setup project in vs.net 2003)
--
AccoN Accountants & Adviseurs
ICT Project Bureau
Postbus 5090
6802 EB Arnhem
The Netherlands

tel. +31 (0)26-3842384
fax. +31 (0)26-3630222
mobile: +31 (0)6-25388935
http://www.accon.nl
 
Hey there,

an idea maybe?

you can launch custom scripts at different stages in the install, so after
the setup and installed the service you could call
"net start <servicename>"

Dan.
 
Here is how you could do it:
- Extend the ServiceInstaller class and register an Event handler for the
base class "Committed" event in the class constructor.
- In your Event handler you just create an instance of the ServiceController
class for your service and call it's Start method.
- Optionally you can wait for the service to start by calling
ServiceController .WaitForStatus before you close the ServiceController by
calling Close.

Willy.
 
Back
Top