Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching a service from msi installer that depends on assemblies installed by the msi

I'm using WiX to write a MSI installer to start a service that depends on DLLs installed by the MSI. On Vista, the DLLs become added to the global assembly cache in the MSI's InstallFinalize phase, so I can't use the built-in service starting command in WiX. That one tries to start the service before the DLLs are in the GAC, and fails. The solution seems to be to use a custom action instead [1], and run that after InstallFinalize.

The custom action I used was starting the service with sc. Everything works fine when running the installer as an administrator, but running as a regular user doesn't work. The installer will elevate privileges for the actual install phase, but will drop them after finalizing the installation, and starting the service with sc as a non-privileged user will fail. Setting the custom action to be deferred and no-impersonate to get admin privileges won't work either after InstallFinalize [2].

As a final kludge, I tried to add <Condition>Privileged</Condition> to the WiX file to tell the user that the installer needs to be run as Administrator, but I couldn't get that to work either. The Privileged value gets set to 1 during the installation, maybe when the main install sequence is given higher privileges.

So has anyone else ran into the combination of Vista, non-Administrator user, installer needs to start a service and service needs stuff that goes into GAC during installation to run? Is there any kind of working general approach to this?

[1] http://www.mail-archive.com/[email protected]/msg09162.html

[2] http://www.mail-archive.com/[email protected]/msg15381.html

like image 548
rsaarelm Avatar asked Nov 28 '25 21:11

rsaarelm


1 Answers

This is one of those times when the easiest solution is just to schedule a reboot.

like image 195
saschabeaumont Avatar answered Dec 01 '25 18:12

saschabeaumont



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!