microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
109.57k stars 6.46k forks source link

Apps run with Keyboard Manager do not respect the selected elevation mode when running PowerToys in administrator #32206

Open jacko-png opened 5 months ago

jacko-png commented 5 months ago

Microsoft PowerToys version

0.79.0, 0.80.0

Installation method

PowerToys auto-update

Running as admin

Yes

Area(s) with issue?

Keyboard Manager

Steps to reproduce

I'll put details in brackets

  1. Start PowerToys in Administrator (Always run as adminstrator)
  2. Remap a chord to start an app (Win + T to start Windows Terminal)
    • You can follow KBM → Remap a shortcut → Win + T → Action: Run Program → Select Program → type wt in the directory field, close the terminal window, and copy and paste the directory field contents to the file name field)
  3. Set the elevation to normal
  4. Save the confuration, hit Win + T, and find that the command prompt is in administrator mode

✔️ Expected Behavior

Windows Terminal, the app opened by a remapped shortcut, is opened with normal privileges

❌ Actual Behavior

Windows Terminal, the app opened by a remapped shortcut, is opened with adminstrator privileges

Other Software

Windows Terminal 1.19.10821.0 Windows 10 22H2 build 19045.4170 UAC Settings is set to Never Notify (i.e. skip administrator password entry)

github-actions[bot] commented 5 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

htcfreek commented 5 months ago

@jacko-png Can you please upload some screenshots and a /bugreport. This would be very helpful.

jacko-png commented 5 months ago

https://github.com/microsoft/PowerToys/assets/114323964/092d4218-9aae-4d82-9e46-91c9f9485cbc

Curstantine commented 5 months ago

I can reproduce this issue too. Pretty annoying and unsafe. I didn't realize but I've been using admin mode to run different shell scripts for weeks now :(

image

https://github.com/microsoft/PowerToys/assets/69104500/655ec874-47dd-42b4-9407-fa9cc4d7fa71

htcfreek commented 5 months ago

@jacko-png The run as administrator problem is logical for me even if isn't what users are expecting. It should be reworked.

But you wrote something about a wrong working directory. And I don't understand exactly how this problem behaves. Can you post a screenshot for this too please.

jacko-png commented 5 months ago

<removed to keep the scrolling clean, I had screenshots and a description of the working directory issue which is separate>

htcfreek commented 5 months ago

@jacko-png Regarding the wt issue I suggest you to check the wt documentation. I imagine that they have a working dir parameter.

jacko-png commented 5 months ago

Yes, the -d option does this. It's not listed in the --help page, however, so I had to find it on MSDN. For any future commenters, let's return this thread to the elevation issue.

htcfreek commented 5 months ago

Yes, the -d option does this. It's not listed in the --help page, however, so I had to find it on MSDN. For any future commenters, let's return this thread to the elevation issue.

Can you please update the issue description to only describe the elevation issue and add a note that the folder thing is caused by wt. Currently tytle and description are different and this is confusing.

jacko-png commented 5 months ago

Good idea 👍. I was thinking of ways to clean it up and forgot I could edit.

Feejus commented 5 months ago

I have been contemplating a potential enhancement or feature request regarding the search functionality. Currently, when searching for the Command Prompt (Alt+Tab), there is no apparent option to launch it with administrative privileges directly from the search results. I would like to propose the ability to right-click or use an alternative mechanism within the search results to open the Command Prompt in Administrator mode. This would streamline the process of executing commands that require elevated permissions without the need for additional steps.

jacko-png commented 5 months ago

@Feejus You could map something like Shift+Win+T to Command Prompt and set it to run in administrator mode. That works just fine, the issue here is that we can't run it in normal mode if PowerToys is run in administrator, which I may or may not need to have to do at some point.

Does your feature request relate to this issue, which is about administrator PowerToys not starting programs in normal mode?

Feejus commented 5 months ago

@jacko-png

As to your question, I am afraid no.

When I press "Alt+Space" with PowerToys running, and search for CMD or Terminal, the search results allow me to open these applications. However, when I launch them through this method, they start in a regular user session, without elevated administrative privileges.

If I search in the Start menu I see an option to run CMD as administrator, the alternative is to right-click the search and I get a menu which has "run as admin".

Thanx

jacko-png commented 5 months ago

As to your question, I am afraid no.

You're in the wrong thread. This is a bug, and that's a feature request. You're talking about Power Toys Run, and we're talking about Keyboard Manager.

By the way, press Ctrl + Shift + Enter next time you try. Should be able to run an administrator command prompt from PowerToys Run.

jacko-png commented 5 months ago

@jacko-png Can you please upload some screenshots and a /bugreport. This would be very helpful.

@htcfreek Wait did the bug report not upload? I'll try again.

jacko-png commented 5 months ago

PowerToysReport_2024-04-04-12-10-16.zip

jacko-png commented 5 months ago

@jacko-png The run as administrator problem is logical for me even if isn't what users are expecting. It should be reworked.

For example, PowerToys Run launches software in normal mode unless you hold Ctrl + Shift, even in administrator mode.

https://github.com/microsoft/PowerToys/assets/114323964/93624fd9-8cc5-4d7b-9e24-1edc85382553

The video shows a normal command prompt and that PowerToys is running as administrator.

Feejus commented 5 months ago

As to your question, I am afraid no.

You're in the wrong thread. This is a bug, and that's a feature request. You're talking about Power Toys Run, and we're talking about Keyboard Manager.

By the way, press Ctrl + Shift + Enter next time you try. Should be able to run an administrator command prompt from PowerToys Run.

Thanx for clarification. I very much appreciate it. The reason I did not raise it as FR is that this would work equally as well for me. I.E if the Powertoys is running in Admin and I run CMD, it should run it with admin privileges.

ThiagoRangel7 commented 5 months ago

In my tests, I noticed that this bug also happens with other UWP apps (like Notepad), but it doesn't happen with desktop apps (like Excel, Photoshop, cmd etc). It would be great if anyone else can test it and let us know.

You can check if an app is running elevated with the Task Manager (go to the Details tab > Right click the column names > Select columns > Check Elevated).

htcfreek commented 5 months ago

@jaimecbernardo Hot fix possible?