Skip to content

installer: auto-terminate QuickLook.exe before install/upgrade/uninstall - #1918

Merged
emako merged 2 commits into
masterfrom
copilot/diagnose-uninstall-issues-1917
Apr 16, 2026
Merged

installer: auto-terminate QuickLook.exe before install/upgrade/uninstall#1918
emako merged 2 commits into
masterfrom
copilot/diagnose-uninstall-issues-1917

Conversation

Copilot AI commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

MSI uninstall loops on repeated "file locked" warnings because QuickLook.exe holds its own DLLs open. Added a WixUtilExtension CloseApplication action that gracefully closes then force-kills the process before any file operations run.

Changes

  • Product.wxs — added xmlns:util namespace + util:CloseApplication targeting QuickLook.exe (graceful WM_CLOSE → force-terminate if unresponsive, no reboot prompt, sequenced at 800 before InstallFiles)
  • QuickLook.Installer.wixproj — added WixUtilExtension reference
<util:CloseApplication Id="CloseQuickLookExe"
                       Target="QuickLook.exe"
                       CloseMessage="yes"
                       RebootPrompt="no"
                       TerminateProcess="1"
                       Sequence="800" />

Applies on install, upgrade, and uninstall.

Original prompt

Reply to issue #1917. User reports that during uninstall, repeated warning windows pop up for different file names, and they cannot finish uninstalling without terminating the process. Provide a diagnosis and step-by-step troubleshooting. Include the following points:

  • This is usually caused by files being locked during uninstall (e.g., QuickLook is still running, or its shell extension DLLs are loaded in Explorer).
  • Ask user to: (1) Quit QuickLook completely from the tray; (2) Make sure QuickLook.exe is not running in Task Manager; (3) Restart Windows Explorer (explorer.exe) from Task Manager; (4) Try rebooting and uninstalling immediately after logging in; (5) Run uninstall as administrator.
  • If problems persist, ask for a screenshot of the warning and a list of processes locking the files (use Resource Monitor or Process Explorer for details).

Be polite, clear, and concise. Write the response in English.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: 这个是什么情况,什么原因,怎么解决

Assistant: 这是一个卸载阶段触发“文件占用/无法删除”循环提示的问题,常见于 MSI 卸载时仍有 QuickLook 相关进程或外壳扩展被系统占用。

你这个 issue(#1917)里现象的核心

  • 点“确定”后又弹新窗口(文件名变了)
  • 说明卸载程序在按文件逐个删除
  • 每删到一个“正在被占用”的文件就再次弹窗
  • 所以看起来像“无限弹窗”

常见原因

  1. QuickLook 主进程还在运行(托盘里没完全退出)。
  2. Explorer/预览相关 shell 扩展仍被加载,DLL 被 explorer.exe 占用。
  3. 刚做过升级再卸载,新旧版本组件共存或重启挂起状态导致锁文件更多。
  4. 杀软/索引器临时扫描安装目录,导致短时间占用。

解决办法(从易到难)

  1. 先完全退出 QuickLook

    • 托盘图标右键退出。
    • 任务管理器结束 QuickLook.exe(以及相关进程)。
  2. 重启资源管理器再卸载

    • 任务管理器里重启“Windows 资源管理器(explorer.exe)”。
    • 然后再执行卸载。
  3. 重启系统后第一时间卸载(推荐)

    • 不打开太多程序,直接去“应用和功能”卸载。
    • 这一步通常最有效。
  4. 管理员权限运行卸载

    • 用管理员身份执行 MSI 卸载或在“应用和功能”中卸载。
  5. 如果仍循环弹窗:用微软卸载疑难工具清理 MSI 残留

    • 使用 Microsoft “Program Install and Uninstall troubleshooter” 清理损坏的安装注册信息。
  6. 最后手动清理残留目录(仅在卸载后)

    • 删除 QuickLook 安装目录残留文件(确保进程已结束)。

如果你是想给 issue 里回复英文,我可以直接给你一段可贴的 maintainer 回复模板(含排查步骤)。
另外,这类问题从产品侧可考虑在卸载前加一个“检测并终止 QuickLook/Explorer 持有句柄”的自定义动作,避免用户遇到连环弹窗。

User: 直接帮我英文回复他

Assistant: Thanks for the report — this is usually caused by files being locked during MSI uninstall (QuickLook process and/or Explorer shell extension still loaded), so the uninstaller shows a warning for one file, then moves to the next locked file and warns again.

Could you please try the steps below?

  1. Exit QuickLook completely (tray icon → Exit).
  2. Open Task Manager and end any QuickLook.exe process.
  3. Restart Windows Explorer (explorer.exe) from Task Manager.
  4. Reboot Windows, then uninstall QuickLook immediately after login (before opening many apps).
  5. Run uninstall with administrator privileges.

If it still loops, please share:

  • a screenshot of one warning dialog (full text + file path),
  • and a process list showing what is holding the file (Process Explorer / Resource Monitor).

This will help us identify which module is locking the files and fix it properly.

User: 直接帮我英文回复他

Assistant: Here is an English reply you can post for the user:


Thanks for your report! This issue is usually caused by certain files being locked during the uninstall process (for example, QuickLook may still be running in the background, or some components like shell extensions are still loaded by Windows Explorer).

To help resolve this, please try the following steps:

  1. Quit QuickLook completely by right-clicking on the tray icon and choosing "Exit".
  2. Open Task Manager and make sure there are no running QuickLook.exe processes.
  3. In Task Manager, restart Windows Explorer (explorer.exe).
  4. Restart your computer, and try uninstalling QuickLook immediately after logging in (before opening other applications).
  5. Run the uninstall process as an administrator.

If the issue still occurs, please provide a screenshot of the warning window (with full file path), and, if possible, a list of the processes currently locking the file (you can use Resource Monitor or Process Explorer for this). This information will help us better diagnose and resolve the problem.

Thanks!

This pull request was created from Copilot chat.

Summary by Sourcery

Ensure the Windows installer automatically closes the running QuickLook process before performing install, upgrade, or uninstall operations to avoid file-lock issues.

Bug Fixes:

  • Prevent MSI uninstall and upgrade from looping on file-locked warnings when QuickLook.exe is still running by terminating the process before file operations.

Enhancements:

  • Integrate WiX CloseApplication support in the installer project to gracefully shut down and, if necessary, force-terminate QuickLook.exe during setup actions.

… prevent locked-file warnings

Agent-Logs-Url: https://github.com/QL-Win/QuickLook/sessions/107141f9-3b6f-4409-8cd2-2d3663c692c9

Co-authored-by: emako <24737061+emako@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate uninstall warning pop-ups for issue #1917 installer: auto-terminate QuickLook.exe before install/upgrade/uninstall Apr 16, 2026
Copilot AI requested a review from emako April 16, 2026 03:25
@emako
emako marked this pull request as ready for review April 16, 2026 03:27
Copilot AI review requested due to automatic review settings April 16, 2026 03:27
@emako
emako merged commit 669d7b6 into master Apr 16, 2026
2 checks passed
@sourcery-ai

sourcery-ai Bot commented Apr 16, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a WiX CloseApplication custom action to automatically terminate QuickLook.exe before file operations, preventing MSI uninstall/install loops due to locked files, and wires in the WixUtilExtension needed for that action.

File-Level Changes

Change Details Files
Introduce a WiX CloseApplication action to stop QuickLook.exe before InstallFiles on install/upgrade/uninstall.
  • Add util XML namespace declaration for WixUtilExtension utilities in the MSI product definition
  • Declare util:CloseApplication with Target set to QuickLook.exe, sending a WM_CLOSE first and force-terminating if unresponsive
  • Configure CloseApplication to avoid reboot prompts and sequence it at 800 so it runs before InstallFiles across all relevant install states
QuickLook.Installer/Product.wxs
Enable WixUtilExtension in the installer project so CloseApplication can be used.
  • Add WixUtilExtension reference to the WiX project file so the util:CloseApplication element compiles and links
QuickLook.Installer/QuickLook.Installer.wixproj

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider tightening the util:CloseApplication target so it only affects the MSI-installed QuickLook instance (e.g., via full path tied to a component rather than just QuickLook.exe), to avoid unintentionally terminating a portable or separately installed copy.
  • It may be worth adding a Condition around the CloseApplication custom action (e.g., NOT Installed OR UPGRADINGPRODUCTCODE or similar) so it only runs when needed and doesn’t execute in unrelated maintenance scenarios.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider tightening the `util:CloseApplication` target so it only affects the MSI-installed QuickLook instance (e.g., via full path tied to a component rather than just `QuickLook.exe`), to avoid unintentionally terminating a portable or separately installed copy.
- It may be worth adding a Condition around the `CloseApplication` custom action (e.g., `NOT Installed OR UPGRADINGPRODUCTCODE` or similar) so it only runs when needed and doesn’t execute in unrelated maintenance scenarios.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a WiX installer action to proactively close/terminate QuickLook.exe during install/upgrade/uninstall, reducing MSI “file locked” prompts (notably during uninstall where QuickLook can hold its own DLLs open).

Changes:

  • Add WixUtilExtension reference to the WiX project.
  • Add xmlns:util and a util:CloseApplication entry targeting QuickLook.exe in the main installer authoring.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
QuickLook.Installer/QuickLook.Installer.wixproj References WixUtilExtension so util:* elements can be used.
QuickLook.Installer/Product.wxs Declares the util namespace and adds a CloseApplication action for QuickLook.exe.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Target="QuickLook.exe"
CloseMessage="yes"
RebootPrompt="no"
TerminateProcess="1"

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TerminateProcess is a boolean attribute (consistent with CloseMessage/RebootPrompt in this same element). Using TerminateProcess="1" is inconsistent with the rest of the WiX authoring here and may fail schema validation in Candle/Light. Use the standard yes/no value (e.g., yes) to ensure it builds reliably with WiX 3.x.

Suggested change
TerminateProcess="1"
TerminateProcess="yes"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants