title: Launching a service from msi installer that depends on assemblies installed by the msi
body: <p>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 <code>InstallFinalize</code> 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 <code>InstallFinalize</code>.</p>
  
  <p>The custom action I used was starting the service with <code>sc</code>. 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 <code>sc</code> 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 <code>InstallFinalize</code> [2].</p>
  
  <p>As a final kludge, I tried to add <code>&lt;Condition&gt;Privileged&lt;/Condition&gt;</code> 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 <code>Privileged</code> value gets set to 1 during the installation, maybe when the main install sequence is given higher privileges.</p>
  
  <p>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?</p>
  
  <p>[1] <a href="http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg09162.html" rel="nofollow noreferrer">http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg09162.html</a></p>
  
  <p>[2] <a href="http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg15381.html" rel="nofollow noreferrer">http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg15381.html</a></p>