Apps run with Keyboard Manager do not respect the selected elevation mode when running PowerToys in administrator
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
- Start PowerToys in Administrator (Always run as adminstrator)
- 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)
- Set the elevation to normal
- 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)
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:
- PowerToys.Run does not run apps as an admin when in admin mode (#17226), similarity score: 0.77
Closed similar issues:
- Run as Administrator - Applications don't open as Administrator (#4045), similarity score: 0.77
- PowerToys Always in Administrator Mode (#31052), similarity score: 0.76
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
@jacko-png Can you please upload some screenshots and a /bugreport. This would be very helpful.
https://github.com/microsoft/PowerToys/assets/114323964/092d4218-9aae-4d82-9e46-91c9f9485cbc
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 :(
https://github.com/microsoft/PowerToys/assets/69104500/655ec874-47dd-42b4-9407-fa9cc4d7fa71
@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.
<removed to keep the scrolling clean, I had screenshots and a description of the working directory issue which is separate>
@jacko-png Regarding the wt issue I suggest you to check the wt documentation. I imagine that they have a working dir parameter.
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.
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.
Good idea 👍. I was thinking of ways to clean it up and forgot I could edit.
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.
@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?
@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
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 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 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.
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.
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).
@jaimecbernardo Hot fix possible?
So this is a bug? I'd figured it might have just been a natural consequence of how Windows works, considering how any process opened out of an elevated terminal will be elevated as well, but that it doesn't occur with native apps does suggest otherwise...
Any chance we can get some priority on this? It's a rather troublesome bug... In the meantime, I have a workaround for anyone suffering it, though it's not perfect. You can set your shortcut to open Explorer with the target executable as an argument, which will launch it through Explorer and thus unelevated. Caveat is you can't add any extra arguments to it (but you can work around this too by creating a shortcut that launches your desired app with its arguments, then opening that with Explorer... ridiculous as that gets). Just make sure you set KBM to open a new instance "if" Explorer is already running (which it is).
In the meantime, I have a workaround for anyone suffering it, though it's not perfect. You can set your shortcut to open Explorer with the target executable as an argument, which will launch it through Explorer and thus unelevated. Caveat is you can't add any extra arguments to it (but you can work around this too by creating a shortcut that launches your desired app with its arguments, then opening that with Explorer... ridiculous as that gets).
Somehow this is the canonical way of doing it: https://devblogs.microsoft.com/oldnewthing/20131118-00/?p=2643
I am not familiar with how PowerToys spawn processes, but this could be done.
Would love to see an update on this. I'm still facing this issue on 0.94.2 It causes firefox.exe to not launch correctly and windows terminal to always treat powershell as admin instead of a normal user
Update: @IamSmeagol I am not sure when but "Elevation" seems to work when running PowerToys in admin mode. This screenshot is from 0.95.0 and I am not getting elavation prompt.
@ghost could you confirm bug is fixed.
@TekBear I just tested it myself and it's still broken it seems. Even if you have the elevation setting in the shortcut set to normal, it'll still run as admin if PowerToys itself is elevated. Same issue that's always been. I'm on 0.95.0 as well.
I tested with cmd.exe and it works. I am logged in as normal user, Win 11 Ent 23H2, Powertoys is running with setting "restart powertoys as administrator", I get an elevation prompt when shortcut is set to "elevated". As shown:
@AdreKiseque ok so not fixed for everyone. Do you get same result for cmd.exe?
Do you get same result for cmd.exe?
@TekBear
Having this problem for a long time. cmd.exe works. However, wt.exe (windows terminal) does not launch properly. It's always elevated and I don't know how this happens. By the way, many apps crashes when launched by this feature (like Visual Studio and Code) so I'm not able to test other apps for now.
@TekBear It works for cmd, yes, as well as powershell and pwsh. The issue is relegated to UWP apps it seems, something actually brought up earlier in this thread (though I confess I had forgotten so myself until the familiarity of the situation prompted me to scroll up). To note is all the shells launched like this opened in the old conhost.exe rather than Windows Terminal, despite that not being the case when launched from the run dialogue.
@AdreKiseque, yes I had miss that UWP app caveat thanks for pointing that out.
I have updated to v0.95.1 and manually restart Keyboard Manager as normal user to get it to start shortcuts in user mode this seems to work best for me using non-UWP apps.