Dot-Net
WiX - 安裝 Windows 服務並授予權限
我們需要授予使用者啟動、停止和查詢已安裝服務狀態的權限。
在 WiX 2.0 中,這個 xml 可以工作:
<ServiceInstall Id="ServiceInstaller" Type="ownProcess" Name="$(var.ServiceName)" DisplayName="$(var.ServiceName)" Description="Our service description" Start="demand" Account="LocalSystem" ErrorControl="ignore" Interactive="no"> <Permission User="Everyone" ServiceQueryStatus="yes" ServiceStart="yes" ServiceStop="yes" /> </ServiceInstall> <ServiceControl Id="StopService" Stop="both" Remove="uninstall" Name="$(var.OmniVpnServiceName)" Wait="yes" />我們使用的是 WiX 3.0,他們從 Permission 元素中刪除了 Service* 屬性,並且不再允許它成為 ServiceInstall 元素的子元素。
我們如何在 WiX 3.0 中獲得相同的效果?
作為概述,我們需要:
安裝服務:
- 手動啟動
- 在本地系統下作為“ownProcess”執行
- 與桌面非互動
- 解除安裝時停止
授予“所有人”使用者訪問權限:
- 開始
- 停止
- 查詢狀態
在已安裝的服務上。
文件說在 ServiceInstall 元素中使用它:
<util:PermissionEx User="Everyone" GenericAll="yes" ServiceChangeConfig="yes" ServiceEnumerateDependents="yes" ChangePermission="yes" ServiceInterrogate="yes" ServicePauseContinue="yes" ServiceQueryConfig="yes" ServiceQueryStatus="yes" ServiceStart="yes" ServiceStop="yes" />我沒試過
util 命名空間是
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"