Fix per-user installer directory permissions to resolve Monaco preview handler ACCESS DENIED error#29
Draft
Fix per-user installer directory permissions to resolve Monaco preview handler ACCESS DENIED error#29
Conversation
Co-authored-by: lei9444 <39758135+lei9444@users.noreply.github.com>
…preview handler compatibility Co-authored-by: lei9444 <39758135+lei9444@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] per-user installer安装时C:\Users\leilzh\AppData\Local\PowerToys这个目录被加了奇怪的权限导致加载PowerToys.MonacoPreviewHandlerCpp.dll ACCESS DENIED
Fix per-user installer directory permissions to resolve Monaco preview handler ACCESS DENIED error
Jun 29, 2025
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.
Problem
When PowerToys is installed using the per-user installer, it installs to
%LOCALAPPDATA%\PowerToys(e.g.,C:\Users\[username]\AppData\Local\PowerToys). During installation, Windows Installer may set restrictive permissions on this directory that prevent preview handlers from loading their DLLs properly, resulting in "ACCESS DENIED" errors when trying to loadPowerToys.MonacoPreviewHandlerCpp.dll.Root Cause
Preview handlers in Windows run in restricted security contexts through Explorer. When the installation directory has permissions that are too restrictive, these preview handler processes cannot access the required DLL files, causing preview functionality to fail.
Solution
Added a new custom action
FixPerUserInstallDirectoryPermissionsCAthat:FILE_ALL_ACCESS)FILE_GENERIC_READ | FILE_GENERIC_EXECUTE)Implementation Details
FixPerUserInstallDirectoryPermissionsCAinCustomAction.cppProduct.wxsSetNamedSecurityInfo,SetEntriesInAcl)Why This Works
Changes
installer/PowerToysSetupCustomActions/CustomAction.cpp- Added the custom action implementation (+112 lines)installer/PowerToysSetupCustomActions/CustomAction.def- Exported the function (+1 line)installer/PowerToysSetup/Product.wxs- Integrated custom action into installation sequence (+18 lines)The changes are minimal and surgical, affecting only the per-user installation flow without impacting system-wide installations or existing functionality.
Fixes #28.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.