如何使用WiX安装和启动Windows服务

Ray*_*Ray 59 installer windows-services wix autostart

我试图在Wix中使用下面的代码.

但是在安装时,安装程​​序在状态下冻结了3分钟:启动服务,然后我收到此消息"Service Jobservice无法启动.验证您是否具有足够的权限来启动系统服务".我的代码有什么问题吗?我可以要求用户在安装过程中输入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>
Run Code Online (Sandbox Code Playgroud)

sas*_*ont 74

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

    <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>
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,它现在工作正常.我使用的可执行程序不是Windows服务exe,现在我正在使用VB编写的Windows服务来启动它. (2认同)

Dan*_*aan 15

我发现此页面上的解决方案将正确安装服务,但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>
Run Code Online (Sandbox Code Playgroud)

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

  • 许多服务都有传递给它们的命令行参数. (11认同)
  • 如果您需要传递参数来启动它,那么该服务可能无法正确地粘附到Windows API (4认同)

Ric*_*hip 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" />
Run Code Online (Sandbox Code Playgroud)