2013-06-20 74 views
2

我正在尝试使用WIX安装windows服务。 Windows服务安装罚款,如果我检查服务经理,我能看到已安装我的服务内,尝试启动,如下图所示:WIX安装windows服务

logservice

后3〜4分钟,我得到错误需要足够的特权。请参阅图像错误消息:

setupinstalling

如果我运行Windows服务设置手动那么它在启动时没有任何问题,安装的罚款。我做错了什么人都可以帮忙?

以下是我使用的代码:

public ProjectInstaller() 
     {this.ServiceProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller(); 
      this.ServiceInstaller = new System.ServiceProcess.ServiceInstaller(); 
      // 
      // ServiceProcessInstaller 
      // 
      this.ServiceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalService; 
      this.ServiceProcessInstaller.Password = null; 
      this.ServiceProcessInstaller.Username = null; 
      // 
      // ServiceInstaller 
      // 
      this.ServiceInstaller.ServiceName = "Service"; 
      this.ServiceInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic; 
     } 

以下是我的维克斯代码:

<File Id='SetupService' Name='SetupService' DiskId='1' Source='setup.exe' KeyPath='yes'/> 
<ServiceInstall Id="ServiceInstaller" Type="ownProcess" Name="SetupService" DisplayName="DataLogsetup" Description="Service" Start="auto" Account="[SERVICEACCOUNT]" Password="[SERVICEPASSWORD]" ErrorControl="normal"/> 
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="SetupService" Wait="yes" /> 

我也试图在[本地服务]通过在帐户,但我仍然我得到了同样的错误。无论如何,我可以使用WIX安装我的服务吗?

回答

2

我看到几个原因可能会导致失败的位置:

  1. 你是不是在你的方法结束通话

    Installers.Add(this.ServiceInstaller); Installers.Add(this.ServiceProcessInstaller);

The Installers.Add(..)行实际上应该将服务添加到服务表。 See the example at the end of this page

  1. 据我所知,安装类不支持维克斯,自定义操作来代替。你如何从WIX调用你的代码?

  2. WIX有一个用于安装服务的<ServiceInstall>元素。虽然不是全能的,但这个元素非常强大并且是安装Windows服务的首选方法。请参阅Installing and starting a Windows Service using WiX

+0

:谢谢您的答复。我可以安装该服务。我在product.wxs中做了一些更改。在工作之下提供。 – reapen

+1

reapen