2009-12-21 74 views
44

我試圖在Wix中使用下面的代碼。如何使用WiX安裝和啓動Windows服務

但是在安裝時,安裝程​​序在狀態上凍結了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> 
+1

我刪除了「Wait =」yes「」,現在安裝正常,但在Windows任務管理器中服務「JobService」的狀態爲「停止」,它如何自動啓動?謝謝。 – Ray

+0

ServiceInstall元素中的Start =「auto」 –

回答

58

下面的代碼對我的作品......沒有必要提示用戶名/密碼:)

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

感謝您回答我的問題,但即使在重啓系統後,服務的狀態仍「停止」。 – Ray

+0

一旦安裝完成但在重新啓動之前它會手動啓動嗎? – saschabeaumont

+2

謝謝,它現在工作正常。我使用的可執行程序不是Windows服務的exe文件,現在我正在使用VB中寫入的windows服務來啓動它。 – Ray

12

,我發現這個頁面上的解決方案將正確安裝服務,但該元素的ServiceControl不會啓動服務。

比較wix安裝的服務和手動安裝的服務(「JobService.exe/install」),「可執行文件的路徑」字段缺少啓動開關。使用ServiceInstall的arguments屬性修復了這個問題;

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

很長一段時間潛伏者,這是我在這裏的第一篇文章 - 我希望它可以幫助某人。

+4

如果您需要傳遞一個參數來啓動它,那麼服務可能沒有正確地遵守Windows API – saschabeaumont

+9

許多服務都將命令行參數傳遞給它們。 –