2017-05-15 37 views
0

我有一個WiX腳本,用於安裝服務。我在Component下有ServiceInstall元素。將服務配置爲延遲自動啓動(並在XP/2003上自動啓動)

<ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes" 
       Name="abc" DisplayName="abc service" 
       Description="It does this" Start="auto" 
       Account="LocalSystem" ErrorControl="normal" Interactive="no"> 
    <ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall ="yes" /> 
</ServiceInstall> 

而且從代碼看到,我使用ServiceConfigDelayedAutoStart標誌設置服務延遲自動啓動方式啓動。然而,維克斯編譯器(candle.exe)觸發警告:

警告CNDL1150:ServiceConfig功能在 Windows安裝程序的SDK文檔「不是[工作]如預期。」考慮用WixUtilExtension ServiceConfig元素替換 ServiceConfig。

因此,我嘗試使用util:ServiceConfig ^,但是這個元素沒有任何屬性來控制服務啓動。

^命名空間導入:

<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' 
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 

因此,問題只是:

  1. 如何設置服務啓動時自動(延時啓動)?
  2. 如何有條件地只在Vista和更高版本上做,並在Windows XP/2003上正常(自動)?

回答

1

在檢查source之後,目前看起來似乎不可能。 Wix只能用SERVICE_CONFIG_FAILURE_ACTIONS參數調用ChangeServiceConfig2 function而不用SERVICE_CONFIG_DELAYED_AUTO_START_INFO

如果我是你,我會寫一個自定義操作,在CMD中調用sc config abc start=delayed-auto

關於你的第二個問題加VersionNT版本條件(VersionNT >= 600所有比Vista更高版本)

+0

那麼理想情況下,不應該給的警告。 – Ajay