3

I have a java application. I have made an scansol-agent-app.exe file from that i need to make an installer with WiX. Below there is a code of scansol-agent.wxs file. I need to install this app as windows service. Servise installs well, but don't starts. Windows shows me an error: “Service failed to start - Verify that you have sufficient privileges to start system services” I tried all variants that could find, but no any results. How can i start this service?

    <?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
   <Product Id="*" 
            UpgradeCode="{EB6B8302-C06E-4bec-ADAC-932C68A3A98D}" 
            Name="Scansol Agent Application Service" 
            Version="0.0.1" 
            Manufacturer="ScienceSoft" 
            Language="1033">

      <Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" Manufacturer="ScienceSoft"/>
      <Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>

      <Property Id="WHSLogo">1</Property>

    <WixVariable Id="WixUILicenseRtf" Value="license.rtf" />

      <UI>  
        <Property Id="ApplicationFolderName" Value="WiX Demo" />
        <Property Id="WixAppFolder" Value="WiXxperMachineFolder" />
        <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
        <UIRef Id="WixUI_InstallDir" />
        <!-- Skip license dialog -->
        <Publish Dialog="WelcomeDlg"
             Control="Next"
             Event="NewDialog"
             Value="InstallDirDlg"
             Order="2">1</Publish>
        <Publish Dialog="InstallDirDlg"
             Control="Back"
             Event="NewDialog"
             Value="WelcomeDlg"
             Order="2">1</Publish>

          <!--<Property Id="DefaultUIFont">DlgFont8</Property>-->
          <TextStyle Id="DlgFont8" FaceName="Tahoma" Size="8" />
          <TextStyle Id="DlgTitleFont" FaceName="Tahoma" Size="8" Bold="yes" />
        <Dialog Id="InstallDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
          <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
            <Text>{\DlgTitleFont}Ready to Install</Text>
          </Control>
          <Control Id="Install" Type="PushButton" X="304" Y="243" Width="56" Height="17"
            Default="yes" Text="Install">
            <Publish Event="EndDialog" Value="Return" />
          </Control>
        </Dialog>     
      </UI>

      <Directory Id="TARGETDIR" Name="SourceDir">
         <Directory Id="ProgramFilesFolder"  Name="PFiles">
            <Directory Id="INSTALLDIR" Name="ScansolAgent">
               <Component Id="ApplicationServiceInstall" Guid="{908B7199-DE2A-4dc6-A8D0-27A5AE444FEA}">
                    <File Id='ApplicationFile1' Source="scansol-agent-app.exe" DiskId='1' KeyPath='yes' Vital='yes'/>
                    <File Id="ApplicationFile2" Source="config.cfg"  DiskId='1' KeyPath='no' Vital='yes'/>
                <ServiceInstall
                    Id="ServiceInstaller"
                    Type="ownProcess"
                    Vital="yes"
                    Name="ScansolAgentService"
                    DisplayName="Scansol Agent Application Service"
                    Description="File Monitoring and Loading to server"
                    Start="auto"
                    Account="LocalSystem"
                    ErrorControl="ignore"   
                    Interactive="no"
                >
                </ServiceInstall>
                <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="ScansolAgentService" Wait="yes" />
              </Component>
            </Directory>
         </Directory>       
      </Directory>

      <Feature Id="DefaultFeature" Level="1" Title="ScansolAgentAppService">
         <ComponentRef Id="ApplicationServiceInstall" />
      </Feature>
   </Product>
</Wix>
st_zidane
  • 43
  • 1
  • 5
  • Where are you seeing the "Service failed to start..." error? During the install, or when you are starting the service after the install? – bradfordrg May 25 '16 at 13:13
  • Have you tried to install the service manually? Maybe it's just broken or missing some libraries. That is, using "sc" command line tool. – Nikolay May 25 '16 at 18:25
  • I have this error during the install. Service installs. But I cannon start it. When I create installer from same .jar with install4j tool - I don't have any issues! – st_zidane May 26 '16 at 09:17
  • You can also check the events using `eventvwr.exe` to find out what is the reason for this. As @Nikolay pointed out it maybe is some missing library or similar. – taffit May 31 '16 at 10:55

2 Answers2

5

The reasons could be many and vast majority of those were addressed, however, I had a case that none of the answers or suggestions were applicable to it. At the end I found the reason for my case: in the ServiceInstall tag there is an attribute named Account, which in my case was LocalService, however, in my project for the Windows Service, in the generated file I assigned for my service the account to be LocalSystem. So if the service account set in the windows service project does not match to what you later specify in your WiX source file under the ServiceInstall's Account attribute, then the Windows Installer will successfully install your service, however, will fail on starting it. Conclusion, make sure the service accounts match at both places. And again, this might not be your case, but is worth to double check.

Tiger Galo
  • 289
  • 4
  • 15
  • Yeah, thanks. Just wasted a few hours because I was installing to LocalSytem instead of LocalSystem (missing an "s" after the "y"). Pain... – Joseph Willcoxson Nov 12 '21 at 01:41
0

Please see this answer: https://stackoverflow.com/a/65342252/6657445. For this case, because this is not a domain or local user account, try flipping "Interactive" to "yes". I have other services installed this way without issue.

str8ball
  • 111
  • 1
  • 12