How to prevent a Windows user from being removed and created during a patch
I have a project that uses the WiX extension WixUtilExtension to create a user for our Windows services. When I patch the installation (using an .msp), the custom actions RemoveUser and CreateUser are executed.
I开发者_运维知识库 don't want these WiX extension created custom actions to run during a patch.
I can add a condition directly to the custom action (ConfigureUsers) in the InstallExecuteSequence table of the MSI to prevent this, but I have not found a way to handle this in WiX.
Using WiX, how can I prevent RemoveUser and CreateUser from being executed during a patch?
<util:Group Id="LocalAdministrators" Name="Administrators"/>
<DirectoryRef Id="INSTALLLOCATION" DiskId="1">
<Component Id="CreateServiceAccountUser" Guid="{614550A7-C766-4B5D-9BF9-233D07EB3B69}">
<util:User Id="ServiceAccountUser"
CanNotChangePassword="yes"
CreateUser="yes"
Disabled="no"
FailIfExists="no"
LogonAsService="yes"
Name="TestUser"
Password="testuserpw"
PasswordExpired="no"
PasswordNeverExpires="yes"
RemoveOnUninstall="yes"
UpdateIfExists="yes">
<util:GroupRef Id="LocalAdministrators"/>
</util:User>
<RegistryKey Root="HKMU" Key="Software\AMT\WebBrix">
<RegistryValue Name="CreateServiceAccountUser"
Value="Common"
Type="string"
KeyPath="yes" />
</RegistryKey>
</Component>
</DirectoryRef>
You can do that in WiX:
<InstallExecuteSequence>
<Custom Action='ConfigureUsers'
After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
Here are some more conditions
- Action run only during Install Condition: NOT Installed AND NOT PATCH
- Action only runs during removal of MSI Condition: REMOVE
- Action runs during Install and repair Condition: NOT REMOVE
- Action runs during Install and remove Condition: There must be no condition
- Action calls EXE installed by MSI Condition:NOT Installed AND NOT PATCH
- Run on initial installation only: NOT Installed
- Run on initial install or when repair is selected. NOT Installed OR MaintenanceMode="Modify"
- Run when being uninstalled from command line or add / remove menu. REMOVE~="All" OR MaintenanceMode="Remove"
精彩评论