繁体   English   中英

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

[英]How to install and start a Windows Service using WiX

我试图在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>

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

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

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

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

针对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" />

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

<ServiceControl Remove="both" />

我认为这从Regedit中删除了一些内容

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM