Conditional NT service setup
Posted 01 March 2005 - 09:18
In my setup project I have a program, say MyServer.exe, that can be registered as an NT service but ONLY IF the user chooses so. Are there any known ways to install an NT service with MSI conditionally?
MyServer.exe comes in a component MyServer. I couldn't link service registration info in ServiceInstall table to this component as in this case it will be always registered if MyServer gets installed. So I created a separate component MyService with conditional install and made the record in ServiceInstall table refer to this component. If the user selects a checkbox "register MyServer.exe as an NT service" the component MyService is selected for installation. The problem is that in order to register a service with MSI MyService component must have a key path to MyServer.exe.
At first I decided to make the same key paths to MyServer.exe for both MyServer and MyService components, but have only one record in File table - for MyServer component. But that was breaking MSI rules, so when both MyServer and MyService were istalled they didn't get uninstalled. They were not even planned for removal according to MSI log file (Action for both was Null).
So my second move was to make MyService component a copy of the original MyServer component + NT service registration. Only one of the components gets installed during the setup: MyService if user selects a checkbox for NT service registration or MyServer otherwise.
This works fine during an initial install, but now I have problems during an upgrade: I need to tell which of the two components is installed so that not to install the other one. Say if MyServer is installed I shouldn't install MyService and vice versa.
Posted 01 March 2005 - 12:24
Posted 01 March 2005 - 15:17
For now I added a CA that sets INSTALL_MYSERVICE property to "No" if the product is already installed. That saves me from installing MyService during an upgrade.
I can't understand why it's so hard to make conditional installs of services and shortcuts in MSI. It seems quite reasonable to ask users if they really want to register new services (as it might cause additional security breaches) or add a bunchfull of new icons to their cluttered desktops. Should be a common practice, don't you think?
Posted 01 March 2005 - 15:46
Then you simply stop the service and set the startup type to "disabled" with a CA.
This all seems pretty "standard" to me (and simple too).
Posted 01 March 2005 - 16:05
Yet it looks a little bit weird: first to install something then disable it, specially when users specifically told you that they don't need this feature... It'd be much simplier if users could select optional shortcuts or services just like they do with MSI features.
Posted 02 March 2005 - 07:42