3

I wrote an installer a bit back that installs a service that I wanted to start when the installer finished. I put the code to start the service in the OnCommitted method of the ServiceInstaller. I did this because a lot of searches I found on the topic did it this way, but I remember there were also other ways to do it.

In looking back though, I'm not sure if this was the right thing to do.

In particular, the docs say that OnCommitted gets called after the Commit of the installation. Does that also count for uninstalling? I wouldn't want to be trying to start a service I am uninstalling!

Thoughts?

Nicros
  • 5,031
  • 12
  • 57
  • 101
  • Well I can confirm that OnCommitted does NOT get called on uninstall, but still dont know if this is the best way to start a service. – Nicros Mar 28 '11 at 01:10

1 Answers1

1

The recommended approach is to use ServiceControl table. Basically, you create a service control operation which tells Windows Installer to start the service after it's installed.

Cosmin
  • 21,216
  • 5
  • 45
  • 60