Skip to content

Fix RunAsAdmin For CmdPal when PowerToys is running as Admin#39448

Merged
zadjii-msft merged 1 commit intomainfrom
user/yeelam/FixRunAsAdminForCmdPal
May 15, 2025
Merged

Fix RunAsAdmin For CmdPal when PowerToys is running as Admin#39448
zadjii-msft merged 1 commit intomainfrom
user/yeelam/FixRunAsAdminForCmdPal

Conversation

@yeelam-gordon
Copy link
Contributor

@yeelam-gordon yeelam-gordon commented May 15, 2025

Summary of the Pull Request

Since we change the launch method by this PR #39269 , we will start cmdpal as admin too if powertoys run as admin.
The fix is leveraging explorer (which will not run as admin) to start the cmdpal

Moreover, without this fix, some of extension cannot be "loaded" when cmdpal run as admin, e.g. winget will be missing, and my own new extension developed by myself will not be loaded successful as well.

@yeelam-gordon yeelam-gordon requested review from Copilot, vanzue and zadjii-msft and removed request for Copilot and vanzue May 15, 2025 10:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the issue where CmdPal was not being launched as admin when PowerToys runs as admin. The change adjusts the launch method to leverage explorer.exe, which runs with standard user privileges, to start CmdPal.

Comments suppressed due to low confidence (1)

src/modules/cmdpal/CmdPalModuleInterface/dllmain.cpp:220

  • [nitpick] Consider verifying that explorer.exe correctly parses and forwards the command line arguments, and use quotes if needed for paths or arguments with spaces.
std::wstring launchPath = L"explorer.exe x-cmdpal://background";

@yeelam-gordon yeelam-gordon requested a review from vanzue May 15, 2025 10:10
@zadjii-msft
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@zadjii-msft zadjii-msft merged commit 75121ca into main May 15, 2025
16 checks passed
yeelam-gordon added a commit that referenced this pull request May 19, 2025
<!-- 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
Since we change the launch method by this PR #39269 , we will start cmdpal as admin too if powertoys run as admin.
The fix is leveraging explorer (which will not run as admin) to start the cmdpal

Moreover, without this fix, some of extension cannot be "loaded" when cmdpal run as admin, e.g. winget will be missing, and my own new extension developed by myself will not be loaded successful as well.
@hieu-delta
Copy link

how can I apply this fix to mine?

@yeelam-gordon yeelam-gordon self-assigned this Jun 9, 2025
@yeelam-gordon yeelam-gordon added the Product-Command Palette Refers to the Command Palette utility label Jun 9, 2025
@yeelam-gordon yeelam-gordon added this to the PowerToys 0.91 milestone Jun 9, 2025
sadirano pushed a commit to sadirano/PowerToys that referenced this pull request Jun 10, 2025
…ft#39448)

<!-- 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
Since we change the launch method by this PR microsoft#39269 , we will start cmdpal as admin too if powertoys run as admin.
The fix is leveraging explorer (which will not run as admin) to start the cmdpal

Moreover, without this fix, some of extension cannot be "loaded" when cmdpal run as admin, e.g. winget will be missing, and my own new extension developed by myself will not be loaded successful as well.
yeelam-gordon added a commit that referenced this pull request Jun 20, 2025
<!-- 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)? -->
Since we change the launch method by this PR #39269 , we will start cmdpal as admin too if powertoys run as admin.
The fix is leveraging explorer (which will not run as admin) to start the cmdpal

Moreover, without this fix, some of extension cannot be "loaded" when cmdpal run as admin, e.g. winget will be missing, and my own new extension developed by myself will not be loaded successful as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants