PDA

View Full Version : start service that depends on files created after install



tmountjr
08-08-2007, 01:16 PM
Hey, all. I'm trying to repack an SSH server for Windows that, besides this one problem, is really a great product and works very well as a repackaged app. It's originally a simple Inno Setup project, so I extracted the .iss file and used the Editor to create a new MSI that does the same thing. The only problem I'm having is that the service requires that DSA/RSA keys be created before the server can start. These keys are created by the .exe file that is installed with the product.

The service installs fine; starting it, though, is shaping up to be a problem. I've got two options:

1.) I can make the key generation a deferred action that runs "service.exe /KeyGen" after an arbitrary action early in the execution (say, after InstallFiles) and set it as a "Synchronous (Check exit code)" type action. From there, all I have to do is use the service controller to start that service on installation, and problem should be solved. The trouble with that is that sometimes the keys don't finish generating before the StartServices action rolls around, so the service won't start properly and will actually continuously try restarting itself, leading to a hung installation. Even moving StartServices to right before InstallFinalize doesn't solve this problem.

2.) The other option is to let the whole installation run like normal, then use two immediate custom actions - one to run the "service.exe /KeyGen" command and wait for an exit code, then a second vbscript action to run "net start servicename" after that's finished. The problem with that option is that, while it will successfully generate the keys and start the service, the service will quit as soon as msiexec.exe does. Even if I try starting it through WMI it will still quit as soon as the install is finished.

Does anyone have any idea how to generate those keys and get the service to start correctly (and stay started)?