2013-05-22 57 views
0

我目前正在開發一個msi,並且正在從wix項目中啓動服務時遇到一些問題。這是用於複製exe文件(這是服務)和安裝服務的xml。從Wix啓動Windows服務的多個實例

<Component Id='MatcherService' Guid='{81EC2888-DFA6-49BA-829A-5A8354D89310}' Directory='MATCHERDIR'> 
      <File Id='MatchingServer.exe' Source='$(var.Matcher.TargetDir)\MatchingServer.exe'/> 
      <ServiceInstall 
      Id="ServiceInstaller1" 
      Type="ownProcess" 
      Name="Matcher1" 
      DisplayName="Matching Service 1" 
      Description="test" 
      Start="auto" 
      Account="NT AUTHORITY\NETWORK SERVICE" 
      Interactive="no" 
      ErrorControl="normal" 
      Vital="yes"> 
      <util:PermissionEx 
       User="Everyone" 
       GenericAll="yes" 
       ServiceChangeConfig="yes" 
       ServiceEnumerateDependents="yes" 
       ChangePermission="yes" 
       ServiceInterrogate="yes" 
       ServicePauseContinue="yes" 
       ServiceQueryConfig="yes" 
       ServiceQueryStatus="yes" 
       ServiceStart="yes" 
       ServiceStop="yes" /> 
      </ServiceInstall> 
<ServiceControl Id="StartService1" Stop="both" Remove="uninstall" Name="Matcher1" Wait="yes"/> 
</Component> 

這僅安裝服務,當我打開服務,我能夠正常啓動該服務。

我面臨的問題是,我想這個MatchingServer.exe的幾個實例作爲服務運行,我想要30個實例。

我試圖做這樣說:

<Component Id='MatcherService' Guid='{81EC2888-DFA6-49BA-829A-5A8354D89310}' Directory='MATCHERDIR'> 
     <File Id='MatchingServer.exe' Source='$(var.Matcher.TargetDir)\MatchingServer.exe'/> 
     <ServiceInstall 
     Id="ServiceInstaller1" 
     Type="ownProcess" 
     Name="Matcher1" 
     DisplayName="Matching Service 1" 
     Description="test" 
     Start="auto" 
     Account="NT AUTHORITY\NETWORK SERVICE" 
     Interactive="no" 
     ErrorControl="normal" 
     Vital="yes"> 
     <util:PermissionEx 
      User="Everyone" 
      GenericAll="yes" 
      ServiceChangeConfig="yes" 
      ServiceEnumerateDependents="yes" 
      ChangePermission="yes" 
      ServiceInterrogate="yes" 
      ServicePauseContinue="yes" 
      ServiceQueryConfig="yes" 
      ServiceQueryStatus="yes" 
      ServiceStart="yes" 
      ServiceStop="yes" /> 
     </ServiceInstall> 

     <ServiceInstall 
     Id="ServiceInstaller2" 
     Type="ownProcess" 
     Name="Matcher2" 
     DisplayName="Matching Service 2" 
     Description="test" 
     Start="auto" 
     Account="NT AUTHORITY\NETWORK SERVICE" 
     Interactive="no" 
     ErrorControl="normal" 
     Vital="yes"> 
     <util:PermissionEx 
      User="Everyone" 
      GenericAll="yes" 
      ServiceChangeConfig="yes" 
      ServiceEnumerateDependents="yes" 
      ChangePermission="yes" 
      ServiceInterrogate="yes" 
      ServicePauseContinue="yes" 
      ServiceQueryConfig="yes" 
      ServiceQueryStatus="yes" 
      ServiceStart="yes" 
      ServiceStop="yes" /> 
     </ServiceInstall> 

     <ServiceControl Id="StartService1" Stop="both" Remove="uninstall" Name="Matcher1" Wait="yes"/> 
     <ServiceControl Id="StartService2" Stop="both" Remove="uninstall" Name="Matcher2" Wait="yes"/> 
    </Component> 

這顯然給編譯錯誤。我成功了,從這樣一個批處理文件這樣做:

MatchingServer.exe -i 1 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 2 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 3 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 4 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 5 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 6 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 7 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 8 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 9 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 10 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 11 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 12 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 13 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 14 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 15 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 16 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 17 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 18 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 19 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 20 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 21 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 22 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 23 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 24 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 25 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 26 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 27 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 28 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 29 -l "NT AUTHORITY\NETWORKSERVICE" 
MatchingServer.exe -i 30 -l "NT AUTHORITY\NETWORKSERVICE" 

,使自定義操作exeute此批處理文件。但我想要在「內部」這樣做。

我怎樣才能生成30個服務實例的相同的.exe文件,與wix不同的名稱,而不繞過批處理文件?

回答

1

Windows服務並不是爲此而設計的。如果您需要同一臺服務器的30個實例,則需要在Windows中創建30個獨特的服務。

我可能會推薦,但如果每個服務都是副本,那麼您可以通過在您的應用程序中啓動多個線程來實現此目的。如果你有靜態類,你可能需要用app域來做一些奇特的步法,或者你可以產生由master exe(你的服務)管理的30個exes。