我正在写一个MSI,它安装了一个windows服务,并添加了一些该服务使用的DLL。这些DLL是可以使用安装程序添加或删除的功能。
在用户修改已安装的产品之后(等式,添加新功能),则需要重启windows服务。在WiX 3.5中,有没有比调用自定义操作重启服务更优雅的方法呢?
这就是我启动服务的方式。
<ServiceControl Id="StartService" Name="MyService" Start="install" Stop="both" Remove="uninstall" Wait="yes" />编辑:这是完整的组件代码。忽略ids。
<Component Id="MyService" Guid="GUID">
<File Id="MyService"
Source="$(var.BuildDestination)/$(var.NameSpacePrefix).MyService.exe"
KeyPath="yes"
>
</File>
<RemoveFile Id='AppConfigFile' On='uninstall' Name='MyService.exe.Config' />
<User xmlns="http://schemas.microsoft.com/wix/UtilExtension"
Id="ServiceAccount"
CreateUser="no"
FailIfExists="no"
RemoveOnUninstall="no"
UpdateIfExists="yes"
Disabled="no"
LogonAsService="yes"
Name="[ACCOUNT]"
Password="[PASSWORD]" />
<ServiceInstall
Id="MyService"
Type="ownProcess"
Vital="yes"
Name="MyService"
DisplayName="MyService"
Description="MyService"
Start="auto"
Account="[ACCOUNT]"
Password="[PASSWORD]"
ErrorControl="ignore"
Interactive="no">
</ServiceInstall>
<ServiceControl Id="StartService"
Name="MyService"
Start="install"
Stop="both"
Remove="both"
Wait="yes"
>
</ServiceControl>
发布于 2012-02-01 00:11:08
由于服务功能(安装和启动服务的功能)的状态没有更新,服务本身也没有停止和启动。我已经解决了这个问题,将ServiceControl添加到作为独立功能的所有组件中。
<Component Id="Modules1" Guid="GUID">
<File Id="Modules.1" Source="$(var.BuildDestination)/$(var.NameSpacePrefix)Modules.1.dll" KeyPath="yes">
</File>
<ServiceControl Id="StartService1"
Name="MyService"
Start="install"
Stop="both"
Wait="yes"
>
</ServiceControl>
发布于 2012-01-31 06:24:32
这个解决方案对我很有效:
<Component Directory="APPLICATIONFOLDER">
<File Source ="MyService.exe"
KeyPath ="yes" />
<ServiceInstall Id ="MyService.exe"
Name ="My Service"
Account ="LocalSystem"
Start ="auto"
ErrorControl="normal"
Interactive ="no"
Type ="ownProcess"
Description ="My service does stuff."/>
<ServiceControl Id ="MyService.exe"
Name ="My Service"
Start ="install"
Stop ="both"
Remove ="both"
Wait ="no"/>
</Component>https://stackoverflow.com/questions/9066804
复制相似问题