Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Run As Administrator" menu option to Start Menu and Taskbar #4459

Open
wsmelton opened this issue Feb 4, 2020 · 40 comments
Open

Add "Run As Administrator" menu option to Start Menu and Taskbar #4459

wsmelton opened this issue Feb 4, 2020 · 40 comments
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Milestone

Comments

@wsmelton
Copy link

wsmelton commented Feb 4, 2020

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:
image

Example for Taskbar icon:
image

@wsmelton wsmelton added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Feb 4, 2020
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Feb 4, 2020
@DHowett-MSFT
Copy link
Contributor

Your start menu screenshot is a screenshot of our issue template 😄

@abvgdeyoj
Copy link

Afaik this is already possible. (Russian locale - don't panic)
1
2
3

@wsmelton
Copy link
Author

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.

@abvgdeyoj
Copy link

Now, Windows Terminal is not:

  1. An app you have to launch often because of TDI
  2. An app you can't make a "Run as Administrator" shortcut for. (Not directly, but "C:\Windows\system32\cmd.exe /c start /b wt" works)
  3. An app for which the aforementioned shortcut could not be placed in the "Startup" folder, Desktop, Taskbar, key binding, etc...

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.

@DHowett-MSFT DHowett-MSFT added this to the Terminal Backlog milestone Feb 10, 2020
@DHowett-MSFT
Copy link
Contributor

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.

@DHowett-MSFT DHowett-MSFT added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 10, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Feb 10, 2020
@jbpaux
Copy link

jbpaux commented Feb 15, 2020

@erenken
Copy link

erenken commented Feb 15, 2020

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.

@cstueckrath
Copy link

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...

@wsmelton
Copy link
Author

@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.

@cstueckrath
Copy link

@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...

@swinster
Copy link

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....

@abvgdeyoj
Copy link

@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

@dpokluda
Copy link

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)?

@igor-teresco
Copy link

Create a shortcut to "C:\Windows\system32\cmd.exe /c start /b wt", set it to be Run As administrator from properties.

@garyng2000
Copy link

yes, but instead of menu option, can't we have the simple 'sudo bash' equivalent ? we are talking about console/command line here :-)

@zadjii-msft
Copy link
Member

@garyng2000 Unfortunately, it's not that simple. You may be interested in #1032 (comment)

@garyng2000
Copy link

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.

@zadjii-msft
Copy link
Member

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.

@garyng2000
Copy link

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).

@3col
Copy link

3col commented Mar 11, 2020

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\\.\"\"'\""



@dflor003
Copy link

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.

@dflor003
Copy link

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.

@garyng2000
Copy link

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.

@Elepover
Copy link

Elepover commented Apr 3, 2020

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.

  • Drag and drop Windows Terminal shortcut to desktop
  • Hold shift key and right-click desktop
  • Choose "Open PowerShell Window Here"
  • And paste below snippet:
$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.

@schuelermine
Copy link

schuelermine commented Apr 27, 2020

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...

@Melvin-Abraham
Copy link

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.

@schuelermine
Copy link

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.

@spixy

This comment has been minimized.

@wsmelton

This comment has been minimized.

@abvgdeyoj

This comment has been minimized.

@spixy

This comment has been minimized.

@DHowett
Copy link
Member

DHowett commented Jun 9, 2020

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.

@tssva
Copy link

tssva commented Jun 12, 2020

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.

@jbpaux
Copy link

jbpaux commented Jun 12, 2020

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 ;)

@ghost

This comment was marked as off-topic.

@webluke

This comment was marked as off-topic.

@zadjii-msft

This comment was marked as off-topic.

@zadjii-msft
Copy link
Member

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.

@zadjii-msft zadjii-msft added Issue-Task It's a feature request, but it doesn't really need a major design. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Jul 25, 2022
@dmitrykok
Copy link

dmitrykok commented Nov 3, 2024

As I understand, we do have:

Right click on terminal icon on taskbar (1) ⇒ right click on terminal menu terminal itself icon (2) ⇒ we have "Run As Administrator" option:

Image

Nice to have:

Right click on terminal icon on taskbar (1) ⇒ right click on terminal menu, any profile icon (2) ⇒ we have only "Open" option, but want to have also "Run As Administrator" option:

Image

I want to implement it.


And actually we do have option to run as admin any profile from profiles menu, open profiles "drop down" and right click on any profile:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests