如何防止 Windows 用户在补丁期间被删除和创建

发布于 2024-09-06 13:31:01 字数 1554 浏览 4 评论 0原文

我有一个项目,它使用 WiX 扩展 WixUtilExtension 为我们的 Windows 服务创建用户。当我修补安装(使用 .msp)时,将执行自定义操作“RemoveUser”和“CreateUser”。

我不希望这些 WiX 扩展创建的自定义操作在补丁期间运行。

我可以将条件直接添加到 MSI 的 InstallExecuteSequence 表中的自定义操作 (ConfigureUsers)为了防止这种情况发生,但我还没有找到在 WiX 中处理这个问题的方法。

使用 WiX,如何防止在补丁期间执行 RemoveUser 和 CreateUser?

<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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莫相离 2024-09-13 13:31:01

您可以在 WiX 中执行此操作:

<InstallExecuteSequence>
    <Custom Action='ConfigureUsers' 
            After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>

以下是更多条件

  1. 操作仅在安装期间运行
    条件:未安装且未修补
  2. 操作仅在删除 MSI 期间运行
    条件:
  3. 安装和修复期间运行 REMOVE 操作
    条件:NOT REMOVE
  4. 操作在安装和删除期间运行
    条件:必须没有条件
  5. 动作调用MSI安装的EXE
    条件:未安装且未修补
  6. 仅在初始安装时运行:
    未安装
  7. 在初始安装或选择修复时运行。
    未安装或 MaintenanceMode="Modify"
  8. 从命令行或添加/删除菜单卸载时运行。
    REMOVE~=“全部”或 MaintenanceMode=“删除”

You can do that in WiX:

<InstallExecuteSequence>
    <Custom Action='ConfigureUsers' 
            After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>

Here are some more conditions

  1. Action run only during Install
    Condition: NOT Installed AND NOT PATCH
  2. Action only runs during removal of MSI
    Condition: REMOVE
  3. Action runs during Install and repair
    Condition: NOT REMOVE
  4. Action runs during Install and remove
    Condition: There must be no condition
  5. Action calls EXE installed by MSI
    Condition:NOT Installed AND NOT PATCH
  6. Run on initial installation only:
    NOT Installed
  7. Run on initial install or when repair is selected.
    NOT Installed OR MaintenanceMode="Modify"
  8. Run when being uninstalled from command line or add / remove menu.
    REMOVE~="All" OR MaintenanceMode="Remove"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文