代码之家  ›  专栏  ›  技术社区  ›  Atihska

更改配置文件后,服务无法自行启动,并且在运行安装程序时出现权限错误

  •  0
  • Atihska  · 技术社区  · 7 年前

    Service component

    <Component Id="cmp1" Guid="{guid1}">
              <File Id="fil1" KeyPath="yes" Source="$(var.SourceDir)\Service1.exe" />
              <ServiceInstall Id="ServiceInstall1"
                              Type="ownProcess"
                              Name="SCService1"
                              DisplayName="xyz"
                              Description="abc"
                              Start="auto"
                              Account="NT Authority\NetworkService"
                              ErrorControl="normal"
                              Vital="yes" >
                <util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="none" ResetPeriodInDays="1" />
                <ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall="yes" />
              </ServiceInstall>
              <ServiceControl Id="ServiceControl1" Name="SCService1" Start="install" Stop="uninstall" Remove="uninstall" Wait="no" />
    

    Config Component

    <Component Id="cmp2" Guid="{guid2}">
         <File Id="fil2" KeyPath="yes" Source="$(var.SourceDir)\Service1.exe.config"/>
    </Component>
    
    
    <!--XML config file upgrade change-->
    <Component Id="ServiceConfigUpgrades" Guid="{guid3}">
                      <Condition><![CDATA[(INSTALLDIR <> "") AND NOT REMOVE]]></Condition>
                      <CreateFolder />
                      <util:XmlFile Id="UpdateServiceVersion"
                               File="[#fil2]"
                               Action="setValue"
                               Name="sku"
                               Value=".NETFramework,Version=v4.6.2"                                
                               ElementPath="configuration/startup/supportedRuntime" />
    </Component>
    

    我在日志中收到以下错误消息: Error 1920. Service 'Service' (ServiceSvc) failed to start. Verify that you have sufficient privileges to start system services. MSI (s) (B4:18) [14:59:16:380]: Product: XYZ -- Error 1920. Service 'Service' (ServiceSvc) failed to start. Verify that you have sufficient privileges to start system services.

    在这种情况下,我必须手动启动服务,这与安装程序应该能够自己启动服务的理想情况不同。此外,这是一个新安装,我遇到了这个错误,而不是在升级。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Atihska    7 年前

    使用INSTALDIR而不是INSTALLDIR解决了这个问题。我把它拼错了。