简体   繁体   中英

Wix Service Install DLL

I have custom action in Wix to install one of the services for my application.

<Custom Action='ManagedInstall' After="InstallFinalize"/>

    <CustomAction Id="ManagedInstall"
                  Directory='INSTALLDIR'
                  ExeCommand='"[WindowsFolder]\Microsoft.NET\Framework\v2.0.50727\installUtil.exe" /LogToConsole=false ControlService.dll'
                  Impersonate='yes'
                  Return='check'>
    </CustomAction>

This works fine under Windows with XP and 7 (With UAC elevated) any desktop, virtual machine or laptops apart from some of our laptops with encryption.

Assuming it is because installUtil.exe console execution is interrupted by encryption (for some reason, it is the only difference found in between systems), was trying work around a solution for this replacing above custom action code.

        <Component Id='ControlServiceDLL' Guid='27C58A4E-E1A9-4b85-B048-F8BBB1BF3C76'>
          <File Id='ControlService.dll'
              Name='ControlService.dll'
              DiskId='1'
              Source='Data\ControlService.dll'
              Vital='yes'
              KeyPath='yes'/>

          <ServiceInstall
              Id="ControlServiceInstall"
              Type="shareProcess"
              Vital='yes'
              Name='ControlService'
              DisplayName='Control Service'
              Description='Control Service Description'
              Start="demand"
              ErrorControl='ignore'
              Interactive="no">
          </ServiceInstall>

          <ServiceControl Id="StartService" Remove="uninstall" Name="Control Service" Wait="yes" />
        </Component>

And it fails to start initially so I had to remove the Service Control start/ stop command to see is it installs. Yes it installs fine but couldn't start the service manually even.

By Observation found the following that may help someone try to help me in this.

Comparing the Service Properties in 2 different methods I have found below Hope it may helps to someone who can answer my problem.

By using custom action: Service Properties Executable Path shows, C:\\windows\\SysWOW64\\dllhost.exe /Processid:{926E3CF4-B966-4E61-A46B-C3C49F579F7C}

Where as by using Service Install it shows, "C:\\Program Files (x86)\\My Test Company\\Services\\ControlService.dll"

The problem you are/where facing is that you are trying to host a dll as a service. A windows Service is an executable (exe).

If you are using wix 3.0 or higher, go with the non custom action approach, as described here, including the keypath pitfall I fell into: http://blog.tentaclesoftware.com/archive/2009/01/01/21.aspx

You can include application manifest with administrative privileges and so all the events will be created/called under admin account.

If you have an msi then you can go for dotnetinstaller tool, which will convert msi to exe and attach UAC to setup. Hence if the user does not have admin privileges, installer will prompt for it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM