How to install and start a Windows Service using WiX

后端 未结 4 960
無奈伤痛
無奈伤痛 2020-12-04 10:29

I tried to use the codes below in Wix.

But when installing, the installer was freezing for like 3 minutes on status: Starting services, then I got this message \"Ser

相关标签:
4条回答
  • 2020-12-04 10:54

    I found the solution on this page would install the service correctly but that the ServiceControl element would not start the service.

    Comparing the wix installed service with manual installed service ("JobService.exe /install"), the "Path to executable" field was missing a start switch. Fixed this in wix with the arguments attribute of ServiceInstall;

    <File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' Source='JobService.exe'  KeyPath='yes'/>         
      <ServiceInstall
      Id="ServiceInstaller"
      Type="ownProcess"
      Name="JobService"
      DisplayName="123 Co. JobService"
      Description="Monitoring and management Jobs"
      Start="auto"
      Account="[SERVICEACCOUNT]"
      Password="[SERVICEPASSWORD]"
      ErrorControl="normal"
      Arguments=" /start JobService"
      />
      <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="JobService" Wait="yes" />
    </Component>
    

    A long time lurker, this is my first post on here - I hope it helps someone.

    0 讨论(0)
  • For me, it helped for at least one time, I removed service for both install and uninstall

    <ServiceControl Remove="both" />
    

    I assume this removed something from Regedit

    0 讨论(0)
  • 2020-12-04 11:00

    An update for users of version 3.x of WiX. The following code will install and start the service under the local account. Note the Arguments property in the ServiceInstall tag.

    <File Source="$(var.MyService.TargetPath)" />
    <ServiceInstall Id="ServiceInstaller" Name="MyService" Type="ownProcess" Vital="yes" DisplayName="My Service" Description="My Service Description" Start="auto" Account="LocalSystem" ErrorControl="normal" Arguments=" /start MyService" Interactive="no" />
    <ServiceControl Id="StartService" Name="MyService" Stop="both" Start="install" Remove="uninstall" Wait="yes" />
    
    0 讨论(0)
  • 2020-12-04 11:07

    The following code works for me... no need to prompt for username/password :)

        <File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' Source='JobService.exe'  KeyPath='yes'/>         
        <ServiceInstall
          Id="ServiceInstaller"
          Type="ownProcess"
          Name="JobService"
          DisplayName="123 Co. JobService"
          Description="Monitoring and management Jobs"
          Start="auto"
          Account="[SERVICEACCOUNT]"
          Password="[SERVICEPASSWORD]"
          ErrorControl="normal"
          />
          <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="JobService" Wait="yes" />
        </Component>
    
    0 讨论(0)
提交回复
热议问题