Open wsmelton opened 4 years ago
Your start menu screenshot is a screenshot of our issue template 😄
Afaik this is already possible. (Russian locale - don't panic)
My point is to make it more accessible, not that it is not possible.
Having to right click twice from the taskbar icon when it is a command need is inefficient.
Now, Windows Terminal is not:
I don't feel it's that much needed to duplicate an existing feature in such a unsystematic and aesthetically frustrating manner.
I know that we are talking about a product intended mainly for Windows, in which POLP is often neglected, but I do want to bring up that running something by default with elevated privileges is considered to be a bad practice.
This'll also require us to look at the newWindow
key binding and the jump list (#576). I was going to close this and link it to #1032, but it's distinct and tractable enough to stand on its own. Thanks.
Yes please ! Implement it like in pwsh with JumpList tasks : https://github.com/PowerShell/PowerShell/tree/db370dcc794e2f7b3c93e00b4538f1485d937f13/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList
I would actually love to see the Run As Administrator also in the drop-down in the Terminal application where you select which terminal you want. This would make quick access and then I would only do it when I really needed to. I know it would need to start up a new process, but have that process start in the terminal mode I selected and elevated would be awesome.
I see more issues with the whole app concept. I am not a local administrator on my machine, so I elevate with another user. The problem is, that the application is unknown in the context of this user, and because you cannot run the Store as admin or another user, you have to log with every single user you need to run Terminal as and install/update from store...
@cstueckrath that would be how apps work from the Windows Store, everyone of them work in that manner (few exceptions, but not many).
Option would be to just grab the msix file from the release page of this repository and try to install it under the context of just that user.
@wsmelton I know, and I don't mind running calculator or paint as "Apps", but for management tools? They should be available and updateable system wide. Maybe I don't get the concept of all this, but neither of those Store-tools will be usable in my environment - and we don't even talk about those people using Win10 LTSB...
FWIW, I have literally just installed Terminal, it took me around 10-15 seconds to ask myself "how to I run a terminal as an administrator". I clicked feedback, then search open issues for "administrator" and came here....
@cstueckrath The entire "Apps" concept still has a long way to ever get to the point where Windows is a modular system consisting of "Apps", but seeing the developers attitude under Nadella, chances are that Windows will crack open its sources like NetScape back in the days, and Azure (or Outlook, or Xbox Game Pass) will be his main business long before that might happen. As for the LTSB, Microsoft Store is not needed for .appx or .msix to be installed
I would like to add Windows Terminal to Start menu and Taskbar so that when I click it, it will start elevated. How do I do that (without right-clicking)?
Create a shortcut to "C:\Windows\system32\cmd.exe /c start /b wt", set it to be Run As administrator from properties.
yes, but instead of menu option, can't we have the simple 'sudo bash' equivalent ? we are talking about console/command line here :-)
@garyng2000 Unfortunately, it's not that simple. You may be interested in https://github.com/microsoft/terminal/issues/1032#issuecomment-496308808
I don't quite understand the #1032 issue, I assume you meant security.
What would be the difference between 'sudo bash' vs 'right click' then run as Admin on the start menu ?
I don't really need to have the 'current terminal' session to be the parent of the 'elevated shell', but just give me a completely unrelated shell is fine. The usage scenario is just 'I am already in the directory I am in and need elevation for certain tasks'. VS Code can do this too when I try to save files under '\Windows' so why the 'terminal' app cannot ?
Though not a big issue as I already have the habit of just having a few 'admin' shell opened via the 'right click' route.
For sudo bash
, bash is fundamentally still running in an unelevated window, so other unelevated applications can send keystrokes to bash by sending keystrokes to the unelevated terminal window.
When you right-click "run as admin" launch a process, it spawns a new terminal window, and that window is elevated, so it's protected from input being injected by other applications.
This is the fundamental reason there isn't a builtin in-console elevation exe like sudo
on Windows.
I believe that Start-Process -Verb RunAs cmd
(in powershell) will actually create a new elevated console window to run the elevated process, which sounds a lot like what you're looking for.
yes, but that is a lot of typing vs 'sudo bash'(and I have to include the working directory as well which becomes even longer) :-)
I would say 90% of the usage of 'sudo bash' is what I am doing(well may be there are some exotic way in the linux world utilizing what you mentioned but I have no experience of that personally).
I've been using these context menu shortcuts: (https://www.tenforums.com/tutorials/60132-open-bash-window-here-administrator-add-windows-10-a.html)](https://www.tenforums.com/tutorials/60132-open-bash-window-here-administrator-add-windows-10-a.html) to be able to quick and easy open "Open command/bash window here as administrator".
Did few modifications, but some less cryptic way would be nice too:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenTerminalHereAsAdmin]
@="Open Terminal here as administrator"
"Extended"=-
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenTerminalHereAsAdmin\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd -Verb RunAs -ArgumentList '/c start wt -p cmd -d \"\"%V\\.\"\"'\""
[HKEY_CLASSES_ROOT\Directory\shell\OpenTerminalHereAsAdmin]
@="Open Terminal here as administrator"
"Extended"=-
[HKEY_CLASSES_ROOT\Directory\shell\OpenTerminalHereAsAdmin\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd -Verb RunAs -ArgumentList '/c start wt -p cmd -d \"\"%V\\.\"\"'\""
[HKEY_CLASSES_ROOT\Drive\shell\OpenTerminalHereAsAdmin]
@="Open Terminal here as administrator"
"Extended"=-
[HKEY_CLASSES_ROOT\Drive\shell\OpenTerminalHereAsAdmin\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd -Verb RunAs -ArgumentList '/c start wt -p cmd -d \"\"%V\\.\"\"'\""
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenTerminalHereAsAdmin]
@="Open Terminal here as administrator"
"Extended"=-
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenTerminalHereAsAdmin\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd -Verb RunAs -ArgumentList '/c start wt -p cmd -d \"\"%V\\.\"\"'\""
I spent about 5 minutes right clicking on the pinned icon I had for the terminal in my taskbar trying to figure out why I couldn't see "Properties" in there and use that to set it to always run as admin...
Every other application I've ever used on windows lets me set it to run as an administrator automatically using that.
Eventually I figured it was because it was a windows store app which for some reason gives it a completely different menu than everything else, but that really clashes with my expectations as a user.
Putting this automatic "Run as Administrator" feature would at least let us get parity with the functionality we as users are used to.
you just need to do it differently for this. right click then right click on the 'app title' again and you see the menu. weird but that is how it works. true store app like the 'store' itself just can't do this 'run as admin'
you just need to do it differently for this. right click then right click on the 'app title' again and you see the menu. weird but that is how it works. true store app like the 'store' itself just can't do this 'run as admin'
I see the menu, but there's no "Properties" in there that I can set it to always run as administrator.
ah, that is not possible AFAIK for security reason. The WindowsApp is locked down, not even admin can access it so all these tricks of changing property would not work.
Just found this blog post.
Credit: Daniel-Fisher-(lennybacon)
This is a dirty approach (but man ANYWAY IT WORKS): patching lnk
file to force "tick" the "Run as Administrator" checkbox.
$linkFilePath = "C:\Users\$([Environment]::UserName)\Desktop\WindowsTerminal.lnk"
$bytes = [System.IO.File]::ReadAllBytes($linkFilePath)
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes($linkFilePath, $bytes)
Though this is not considered as a clean & elegant approach, it still works perfectly.
About this being a duplicate of existing features: No. In the task bar, for instance, you can't select "Run as Administrator". This is btw also what PowerShell does...
Having an option like "Run as admin" within the context menu for a tab/pane would also be more accessible and let users give a particular tab/pane elevated privileges on demand.
I think having a quick action available directly when right-clicking the taskbar icon is easier than right-clicking once, then right-clicking again on the executable.
Having admin privileges for whole terminal seems wrong to me. Right click submenu would be nice though:
or add this option in settings.json
:
{
...
"commandline": "cmd.exe",
"elevated": true
}
The restriction I see in doing that @spixy (at least from my limited understanding and dealing with other apps in Windows) is Windows won't allow you to spawn a child process as elevated while your are in a non-elevated process (wsl). I hit this at times with various applications now.
Without major changes to how WT works, one way would be to implement it the same as we have in many SysInternals, and that is to add an option to restart the entire process elevated. It 's not the best solution, but it works for me and should solve most of comments regarding "Run as Admin" being hard to find.
@wsmelton interesting, but ConEmu can do it somehow 🤔 (orange = elevated process)
These past few comments are better suited for #632, where we're having an ongoing discussion about why it's okay for third party developers to do this but not us (right now). Please direct further discussion that is not about adding "Run as Administrator" to the Start Menu and Taskbar to #632.
Until this gets implemented those that are double right clicking to run as administrator may instead want to perform a shift-right-click which will bring you directly to a menu with the "Run as administrator" option.
Until this gets implemented those that are double right clicking to run as administrator may instead want to perform a shift-right-click which will bring you directly to a menu with the "Run as administrator" option.
Or just ctrl shit left click to open directly as admin ;)
For
sudo bash
, bash is fundamentally still running in an unelevated window, so other unelevated applications can send keystrokes to bash by sending keystrokes to the unelevated terminal window.When you right-click "run as admin" launch a process, it spawns a new terminal window, and that window is elevated, so it's protected from input being injected by other applications.
This is the fundamental reason there isn't a builtin in-console elevation exe like
sudo
on Windows.I believe that
Start-Process -Verb RunAs cmd
(in powershell) will actually create a new elevated console window to run the elevated process, which sounds a lot like what you're looking for.
@zadjii-msft why not a command like sudo bash
which open the whole windows terminal in a new window with elevated mode and closes the previous terminal window, that way the un-elevated window will be closed and the new window will be in the elevated mode . Let's say i open the terminal using wt -d .
so that it opens in the current directory, but wt opens in non-elevated mode. So if there was an option to enter elevated mode in the current directory, that would be very useful.
Run as Administrator should have been part of the first release. Now that it hasn't I hope they get it right and make it as easy as right-clicking on a profile and selecting "Run as Administrator". It must be a profile > list option in the json config.
Something like this..
"administrator": true
@webluke Boy, would you be interested in #8455, #8514, #5000 and all its linked threads.
FWIW This will probably need #12191 to add --elevate
to the wt
commandline args, and then it should be fairly trivial to add a jumplist entry that points at wt --elevate
.
Description of the new feature/enhancement
Ability, primarily in Windows, to easily open the terminal app in an elevated session. Either via the Start Menu icon, as the PowerShell app does it, or via the taskbar icon.
Example for Start Menu:
Example for Taskbar icon: