Fix preview handlers failing when PowerToys installed in paths with spaces#25
Draft
Fix preview handlers failing when PowerToys installed in paths with spaces#25
Conversation
Co-authored-by: lei9444 <39758135+lei9444@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] preview handler打不开在C:\Users\leilzh\AppData\Local\PowerToys这个目录下
Fix preview handlers failing when PowerToys installed in paths with spaces
Jun 29, 2025
Owner
|
我说的是preview pane的东西 |
Owner
|
我说的是preview pane的东西 |
lei9444
reviewed
Jun 29, 2025
| std::wstring command = installationDir; | ||
| command.append(L"\\WinUI3Apps\\PowerToys.RegistryPreview.exe \"%1\""); | ||
| std::wstring command = L"\"" + installationDir; | ||
| command.append(L"\\WinUI3Apps\\PowerToys.RegistryPreview.exe\" \"%1\""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes preview handlers not working when PowerToys is installed in directories containing spaces, such as
C:\Users\leilzh\AppData\Local\PowerToys.Problem
The issue was that registry command entries for preview handlers were not properly quoting executable paths. When Windows attempts to execute an unquoted command containing spaces, it interprets the space as an argument separator, causing the preview handler to fail to launch.
Root Cause
In
src/common/utils/modulesRegistry.h, the registry commands were constructed like this:This resulted in registry entries like:
Windows would try to execute
C:\Users\leilzh\AppData\Local\PowerToys\WinUI3Apps\PowerToys.RegistryPreview.exeas separate arguments:C:\Users\leilzh\AppData\Local\PowerToys\WinUI3Apps\PowerToys.RegistryPreview.exeSolution
Added proper quoting around the executable path:
This results in properly quoted registry entries:
Changes Made
getRegistryPreviewSetDefaultAppChangeSet()to properly quote the executable pathgetRegistryPreviewChangeSet()to properly quote the executable pathTesting
Fixes #24.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.