66

我尝试在 Wix 中使用以下代码。

但是在安装时,安装程​​序在状态下冻结了 3 分钟:正在启动服务,然后我收到此消息“服务作业服务无法启动。验证您是否有足够的权限来启动系统服务”。我的代码有什么问题吗?并且我可以要求用户在安装过程中输入windows系统的用户名和密码以获得“权限”吗?

非常感谢!

    <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>
4

4 回答 4

82

以下代码适用于我......无需提示输入用户名/密码:)

    <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>
于 2009-12-21T22:54:58.747 回答
17

我发现此页面上的解决方案可以正确安装服务,但 ServiceControl 元素不会启动服务。

将 wix 安装的服务与手动安装的服务(“JobService.exe /install”)进行比较,“可执行文件的路径”字段缺少启动开关。使用 ServiceInstall 的 arguments 属性在 wix 中修复了此问题;

<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>

潜伏了很长时间,这是我在这里的第一篇文章-我希望它对某人有所帮助。

于 2011-04-12T23:58:56.727 回答
6

WiX 3.x 版用户的更新。以下代码将在本地帐户下安装并启动服务。请注意 ServiceInstall 标记中的 Arguments 属性。

<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" />
于 2018-07-26T19:29:09.777 回答
1

对我来说,它至少有一次帮助,我删除了安装和卸载服务

<ServiceControl Remove="both" />

我认为这从 Regedit 中删除了一些东西

于 2019-01-09T13:23:32.733 回答