68

I tried to use the code below in Wix.

But when installing, the installer was freezing for like 3 minutes on status: Starting services, then I got this message "Service Jobservice failed to start. Verify that you have sufficient privileges to start system services". Is there any wrong in my code? And can I ask the user to input the windows system user name and password during the installation to get the "privileges"?

Thanks a lot!

    <File Id='JobServiceEXE' Name='JobService.exe' DiskId='1'
        Source='JobService.exe' Vital='yes' KeyPath='yes'/>         
    <ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes"
        Name="JobService" DisplayName="123 Co. JobService"
        Description="Monitoring and management Jobs" Start="auto"
        Account="LocalSystem" ErrorControl="ignore" Interactive="no" />
    <ServiceControl Id="StartService"  Stop="both" Remove="uninstall"
        Name="JobService" Wait="yes" />
</Component>
starball
  • 20,030
  • 7
  • 43
  • 238
Ray
  • 1,893
  • 7
  • 22
  • 24
  • 1
    I removed the " Wait="yes" ", and installation is OK now, but the status of service "JobService" is "stopped" in Windows Task Manager, how can it be automatically started? Thank you. – Ray Dec 21 '09 at 19:44
  • Start="auto" in the ServiceInstall element – Stephen Drew Aug 08 '13 at 12:32

4 Answers4

84

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>
Eric Andres
  • 3,417
  • 2
  • 24
  • 40
saschabeaumont
  • 22,080
  • 4
  • 63
  • 85
  • Thank you for answering my question, but the status of the service was still "stopped", even after I reboot the system. – Ray Dec 22 '09 at 00:25
  • Will it start manually once installation has completed but before reboot? – saschabeaumont Dec 29 '09 at 02:41
  • 2
    Thanks, it's working fine now. The executable program I used was not a windows service exe, now I'm using a windows service wrote in VB to launch it. – Ray Jan 13 '10 at 19:01
19

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.

Daniel de Zwaan
  • 3,064
  • 25
  • 24
6

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" />
Rickchip
  • 371
  • 1
  • 4
  • 12
1

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

static_cast
  • 1,174
  • 1
  • 15
  • 21