Skip to content

Commit 484789b

Browse files
lei9444yeelam-gordon
authored andcommitted
Fix: File explorer preview didn't work with per-user installation (#40314)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## 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. <!-- Please review the items on the PR checklist before submitting--> ## 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 <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
1 parent e4603b2 commit 484789b

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

installer/PowerToysSetup/ImageResizer.wxs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<?include $(sys.CURRENTDIR)\Common.wxi?>
66

77
<?define ImageResizerAssetsFiles=?>
8-
<?define ImageResizerAssetsFilesPath=$(var.BinDir)Assets\ImageResizer\?>
8+
<?define ImageResizerAssetsFilesPath=$(var.BinDir)WinUI3Apps\Assets\ImageResizer\?>
99

1010
<Fragment>
11-
<DirectoryRef Id="BaseApplicationsAssetsFolder">
11+
<DirectoryRef Id="WinUI3AppsAssetsFolder">
1212
<Directory Id="ImageResizerAssetsFolder" Name="ImageResizer" />
1313
</DirectoryRef>
1414

@@ -18,7 +18,7 @@
1818

1919
<Component Id="Module_ImageResizer_Registry" Win64="yes">
2020
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\CLSID\{51B4D7E5-7568-4234-B4BB-47FB3C016A69}\InprocServer32">
21-
<RegistryValue Value="[INSTALLFOLDER]PowerToys.ImageResizerExt.dll" Type="string" />
21+
<RegistryValue Value="[WinUI3AppsInstallFolder]PowerToys.ImageResizerExt.dll" Type="string" />
2222
<RegistryValue Name="ThreadingModel" Value="Apartment" Type="string" />
2323
</RegistryKey>
2424

installer/PowerToysSetup/Resources.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
187187
<RegistryValue Type="string" Name="ImageResizer_$(var.IdSafeLanguage)_Component" Value="" KeyPath="yes"/>
188188
</RegistryKey>
189-
<File Id="ImageResizer_$(var.IdSafeLanguage)_File" Source="$(var.BinDir)\$(var.Language)\PowerToys.ImageResizer.resources.dll" />
189+
<File Id="ImageResizer_$(var.IdSafeLanguage)_File" Source="$(var.BinDir)\WinUI3Apps\$(var.Language)\PowerToys.ImageResizer.resources.dll" />
190190
</Component>
191191
<Component
192192
Id="ColorPicker_$(var.IdSafeLanguage)_Component"

installer/PowerToysSetup/generateAllFileComponents.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Generate-FileList -fileDepsJson "" -fileListName HostsAssetsFiles -wxsFilePath $
179179
Generate-FileComponents -fileListName "HostsAssetsFiles" -wxsFilePath $PSScriptRoot\Hosts.wxs -regroot $registryroot
180180

181181
#ImageResizer
182-
Generate-FileList -fileDepsJson "" -fileListName ImageResizerAssetsFiles -wxsFilePath $PSScriptRoot\ImageResizer.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\Assets\ImageResizer"
182+
Generate-FileList -fileDepsJson "" -fileListName ImageResizerAssetsFiles -wxsFilePath $PSScriptRoot\ImageResizer.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\WinUI3Apps\Assets\ImageResizer"
183183
Generate-FileComponents -fileListName "ImageResizerAssetsFiles" -wxsFilePath $PSScriptRoot\ImageResizer.wxs -regroot $registryroot
184184

185185
#New+

src/modules/imageresizer/ImageResizerContextMenu/ImageResizerContextMenu.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<TargetName>PowerToys.ImageResizerContextMenu</TargetName>
3535
<!-- Needs a different int dir to avoid conflicts in msix creation. -->
3636
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)\TemporaryBuild\obj\$(ProjectName)\</IntDir>
37-
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\</OutDir>
37+
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\</OutDir>
3838
</PropertyGroup>
3939
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
4040
<ClCompile>

src/modules/imageresizer/ImageResizerLib/ImageResizerLib.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</ImportGroup>
3030
<PropertyGroup Label="UserMacros" />
3131
<PropertyGroup>
32-
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\</OutDir>
32+
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\</OutDir>
3333
</PropertyGroup>
3434
<PropertyGroup>
3535
<TargetName>PowerToys.$(ProjectName)</TargetName>

src/modules/imageresizer/dll/ImageResizerExt.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<PropertyGroup Label="UserMacros" />
2727
<PropertyGroup>
2828
<IgnoreImportLibrary>true</IgnoreImportLibrary>
29-
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\</OutDir>
29+
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\</OutDir>
3030
<TargetName>PowerToys.ImageResizerExt</TargetName>
3131
</PropertyGroup>
3232
<ItemDefinitionGroup>

src/modules/imageresizer/ui/ImageResizerUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<PropertyGroup>
77
<AssemblyTitle>PowerToys.ImageResizer</AssemblyTitle>
8-
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)</OutputPath>
8+
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\</OutputPath>
99
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1010
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
1111
<GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>

src/runner/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow
149149
std::vector<std::wstring_view> knownModules = {
150150
L"PowerToys.FancyZonesModuleInterface.dll",
151151
L"PowerToys.powerpreview.dll",
152-
L"PowerToys.ImageResizerExt.dll",
152+
L"WinUI3Apps/PowerToys.ImageResizerExt.dll",
153153
L"PowerToys.KeyboardManager.dll",
154154
L"PowerToys.Launcher.dll",
155155
L"WinUI3Apps/PowerToys.PowerRenameExt.dll",

0 commit comments

Comments
 (0)