1

我们有一个 wix msi 项目和自定义操作 dll。卸载时,它会启动自定义操作以询问用户密码并验证密码以允许卸载。

自定义动作

<CustomAction Id="CA_Uninstall"
              BinaryKey="BIN"
              DllEntry="ValidatePassword"
              Execute="immediate"
              Impersonate="yes"
              Return="check" />

自定义动作调用

<Custom Action="CA_ProtectUninstall" After="InstallInitialize">
<![CDATA[Uninstalling = "true"]]>
</Custom>

自定义操作 在内部创建 MFC 对话框并验证密码。 自定义操作的一部分

    UINT er = ERROR_INSTALL_FAILURE;

    // launch MFC dialog and validates password
    int ret = dlg.DoModal(hParent);

    er = ret == IDOK ? ERROR_SUCCESS : ERROR_INSTALL_USEREXIT;
    return WcaFinalize(er);

问题: 此自定义操作运行良好并正确验证了密码。每当开始卸载时,Windows 都会在用户上下文中启动进程 msiexec.exe。现在有 2 个 msiexec.exe 进程,1 个在系统中,另一个在用户上下文中。卸载时,当显示密码对话框时,如果用户从用户上下文中终止 msiexec 进程,密码对话框将关闭并且卸载成功而无需验证密码。

谁能帮我解决这个问题?请随时提出任何更好的选项来处理受密码保护的卸载。

自定义操作的卸载日志

MSI (s) (B4:A8) [16:21:20:873]: Doing action: CA_Uninstall
MSI (s) (B4:A8) [16:21:20:873]: Note: 1: 2205 2:  3: ActionText 
Action ended 16:21:20: InstallInitialize. Return value 1.
MSI (s) (B4:90) [16:21:20:885]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI4913.tmp, Entrypoint: ValidatePassword
Action start 16:21:20: CA_Uninstall.
MSI (s) (B4:90) [16:21:29:686]: Leaked MSIHANDLE (252) of type 790541 for thread 20604
MSI (s) (B4:90) [16:21:29:686]: Note: 1: 2769 2: CA_Uninstall 3: 1 
MSI (s) (B4:90) [16:21:29:686]: Note: 1: 2205 2:  3: Error 
MSI (s) (B4:90) [16:21:29:686]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 2769 
ValidatePassword:  ValidatePassword: UILevel=3
DEBUG: Error 2769:  Custom Action CA_Uninstall did not close 1 MSIHANDLEs.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769. The arguments are: CA_Uninstall, 1, 
4

0 回答 0