From 7772bfb777c560cf28de8a03adb4b7ab8fba8c42 Mon Sep 17 00:00:00 2001 From: leileizhang Date: Mon, 7 Jul 2025 09:41:19 +0800 Subject: [PATCH] Fix: File explorer preview didn't work with per-user installation (#40314) ## Summary of the Pull Request This Bug started when the Win11 context menu integration was first introduced by Image Resizer in version v0.60.0. Move Image Resizer to the WinUI3Apps folder to fix file preview issue when PowerToys is installed on a non-C:\Program Files. This aligns with the current structure used by File Locksmith and PowerRename, which are not WinUI 3 apps either, but are already located there. ### Root Cause: When registering an MSIX package, the Windows API adds certain user permissions to the installation folders. Since Image Resizer was previously placed under the main PowerToys directory, these permission changes could prevent Explorer from loading its preview handler properly in per-user scenarios. ![image](https://github.com/user-attachments/assets/a8626314-19ce-4e25-87d6-d5e74a015e68) Interestingly, this issue only affects per-user installs, not machine-wide installs (e.g., to Program Files), even though both locations receive additional permissions. The exact reason is still unclear and requires further investigation. ## PR Checklist - [x] **Closes:** #24384 #29644 #32113 #34139 #37866 #40345 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- installer/PowerToysSetup/ImageResizer.wxs | 6 +++--- installer/PowerToysSetup/Resources.wxs | 2 +- installer/PowerToysSetup/generateAllFileComponents.ps1 | 2 +- .../ImageResizerContextMenu/ImageResizerContextMenu.vcxproj | 2 +- .../imageresizer/ImageResizerLib/ImageResizerLib.vcxproj | 2 +- src/modules/imageresizer/dll/ImageResizerExt.vcxproj | 2 +- src/modules/imageresizer/ui/ImageResizerUI.csproj | 2 +- src/runner/main.cpp | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/installer/PowerToysSetup/ImageResizer.wxs b/installer/PowerToysSetup/ImageResizer.wxs index 9f4602939a..17da272014 100644 --- a/installer/PowerToysSetup/ImageResizer.wxs +++ b/installer/PowerToysSetup/ImageResizer.wxs @@ -5,10 +5,10 @@ - + - + @@ -18,7 +18,7 @@ - + diff --git a/installer/PowerToysSetup/Resources.wxs b/installer/PowerToysSetup/Resources.wxs index 0f4e10f4a6..03a6cfba30 100644 --- a/installer/PowerToysSetup/Resources.wxs +++ b/installer/PowerToysSetup/Resources.wxs @@ -186,7 +186,7 @@ - + PowerToys.ImageResizerContextMenu $(SolutionDir)$(Platform)\$(Configuration)\TemporaryBuild\obj\$(ProjectName)\ - ..\..\..\..\$(Platform)\$(Configuration)\ + ..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\ diff --git a/src/modules/imageresizer/ImageResizerLib/ImageResizerLib.vcxproj b/src/modules/imageresizer/ImageResizerLib/ImageResizerLib.vcxproj index 78b5085908..567de025a3 100644 --- a/src/modules/imageresizer/ImageResizerLib/ImageResizerLib.vcxproj +++ b/src/modules/imageresizer/ImageResizerLib/ImageResizerLib.vcxproj @@ -29,7 +29,7 @@ - ..\..\..\..\$(Platform)\$(Configuration)\ + ..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\ PowerToys.$(ProjectName) diff --git a/src/modules/imageresizer/dll/ImageResizerExt.vcxproj b/src/modules/imageresizer/dll/ImageResizerExt.vcxproj index df038e2c43..c76a8c6cc2 100644 --- a/src/modules/imageresizer/dll/ImageResizerExt.vcxproj +++ b/src/modules/imageresizer/dll/ImageResizerExt.vcxproj @@ -26,7 +26,7 @@ true - ..\..\..\..\$(Platform)\$(Configuration)\ + ..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\ PowerToys.ImageResizerExt diff --git a/src/modules/imageresizer/ui/ImageResizerUI.csproj b/src/modules/imageresizer/ui/ImageResizerUI.csproj index 3a7701607e..aca9f9d81e 100644 --- a/src/modules/imageresizer/ui/ImageResizerUI.csproj +++ b/src/modules/imageresizer/ui/ImageResizerUI.csproj @@ -5,7 +5,7 @@ PowerToys.ImageResizer - ..\..\..\..\$(Platform)\$(Configuration) + ..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\ false false true diff --git a/src/runner/main.cpp b/src/runner/main.cpp index 91f9639c05..527cf15bbb 100644 --- a/src/runner/main.cpp +++ b/src/runner/main.cpp @@ -149,7 +149,7 @@ int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow std::vector knownModules = { L"PowerToys.FancyZonesModuleInterface.dll", L"PowerToys.powerpreview.dll", - L"PowerToys.ImageResizerExt.dll", + L"WinUI3Apps/PowerToys.ImageResizerExt.dll", L"PowerToys.KeyboardManager.dll", L"PowerToys.Launcher.dll", L"WinUI3Apps/PowerToys.PowerRenameExt.dll",