[Keyboard Manager] Honor normal elevation when launching programs - #49571
Open
gavinzhangth wants to merge 1 commit into
Open
[Keyboard Manager] Honor normal elevation when launching programs#49571gavinzhangth wants to merge 1 commit into
gavinzhangth wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
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 of the Pull Request
Closes: #32206
Keyboard Manager's Run program action did not reliably honor
Elevation: Normalwhen PowerToys was running as administrator. The existing path usedCreateProcessWwith Explorer as the parent process. That can create ordinary desktop executables with a non-elevated token, but it does not provide Explorer Shell activation semantics for packaged apps, app execution aliases, shortcuts, or file associations.As a result, apps such as Windows Terminal, Firefox, VS Code, and other applications can start elevated, fail to connect to an existing non-elevated instance, use a different effective context, or fail to start at all. Users may then set mappings to
Elevatedmerely to make them launch, unnecessarily granting administrator rights to the app and all child processes. This can affect profile/IPC behavior, drag and drop, updates, shell integration, and scripts launched by those applications.This PR launches normal, visible program mappings through Explorer's
IShellDispatch2::ShellExecuteWimplementation. ExplicitElevatedandDifferent usermappings retain their existing behavior. Hidden launches keep theCreateProcessWpath because they need its window and process-ID control.PR Checklist
Detailed Description of the Pull Request / Additional comments
CreateProcessWto preserve hidden-window behavior and process tracking.Start inis empty, while leaving Shell targets such as.lnkfiles free to use their own metadata.Start indirectory before launching.IShellDispatch2andShellExecuteWresults instead of reporting success unconditionally.No elevation checks, UAC behavior, code-signing checks, or Code Integrity policies are bypassed.
Validation Steps Performed
KeyboardManagerEngineTestwithtools\build\build.cmd -Platform x64 -Configuration Debug: exit code 0, 0 warnings, 0 errors.vstest.console.exe: 109/109 tests passed.KeyboardManagerEngineandPowerToys.KeyboardManager.dll: exit code 0, 0 warnings, 0 errors.tools\build\build-essentials.cmd -Platform x64 -Configuration Debug: exit code 0, 0 warnings, 0 errors.Normal, and confirmed the target process was not elevated in Task Manager..lnktargets, file-association targets, and applications including Chrome, VS Code, Notion, and Steam.Elevatedstill launch elevated.