作为基于WiX的安装程序的一部分,我有以下具有User
元素的组件(除了具有File
,ServiceInstall
和ServiceControl
元素的其他组件外:< / p>
<Component Id="cmpServiceUser" Directory="TARGETDIR" Guid="PUT-GUID-HERE">
<util:User
Id="ServiceUser"
Name="[ProductName]"
Password="[ServiceUserPassword]"
PasswordNeverExpires="yes"
LogonAsService="yes"
CreateUser="yes"
UpdateIfExists="yes"
RemoveOnUninstall="yes"
/>
</Component>
我决定采用唯一的主要升级方式并将以下元素放在Product
中:
<MajorUpgrade
Schedule="afterInstallInitialize"
DowngradeErrorMessage="A newer version of [ProductName] is already installed."
/>
产品的首次安装按预期工作。在主要升级期间,我希望首先删除用户(在RemoveExistingProducts
期间),然后再次创建用户。但它的行为有所不同:用户几乎在安装结束时被删除 - 例如,在重新启动服务之后(Process Explorer仍然可以告诉我服务的用户名而不是SID) - 如服务启动后,服务的用户被删除了。
经过几个小时的剖析各种安装日志后,我转而查看 UtilExtension 的来源,并可能在scauser.cpp
中找到了解释(稍微重新格式化以获得更好的SO可读性):
// Schedule the removal because the user exists and we don't have any flags set
// that say, don't remove the user on uninstall.
//
// Note: We can't rollback the removal of a user which is why RemoveUser is a
// commit CustomAction.
所以我想在这种情况下,用户的后期删除确实属于RemoveExistingProducts
操作。
感谢您阅读此内容 - 现在问题:是否可以将util:User@RemoveOnUninstall
与主要升级策略配合使用?