Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Conditional NT service setup


5 replies to this topic

RedCat

RedCat
  • Members
  • 11 posts

Posted 01 March 2005 - 09:18

Hi all!

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.

mandy

mandy
  • Members
  • 121 posts

Posted 01 March 2005 - 12:24

Couldn't you just register the component as a service for everyone, then disable the service for users who don't want it using custom action?


RedCat

RedCat
  • Members
  • 11 posts

Posted 01 March 2005 - 15:17

Thanks for your reply, good idea. But then it might be easier to register my NT service using a CA wink.gif) That was my first idea, but I want to try and make it using MSI standard procedures.

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?

mandy

mandy
  • Members
  • 121 posts

Posted 01 March 2005 - 15:46

Your install would still be standard (more so than the other scenarios you've described) - you would use the "InstallServices" action to register the service, and the "StartServices" action to start the service for the users who want the service.

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).


RedCat

RedCat
  • Members
  • 11 posts

Posted 01 March 2005 - 16:05

Yes, it's definately more simple, than what I did. Thanks again! I guess for shortcuts I can use the same scenario.

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.

RedCat

RedCat
  • Members
  • 11 posts

Posted 02 March 2005 - 07:42

One more question: this CA should also work in an upgrade and repair scenario. During an initial install I store users' choice to register\not register NT service in a property. Where'd I get this choice in an upgrade\repair? Store it in the registry?