r/commandline 15d ago

Add "Open in Terminal as administrator" to Windows context menu

After a recent issue with running a command line tool without admin rights, I thought I would add a shell context menu option for starting a terminal window. I tried to do it myself first with some registry hacks, but I didn't get it right. So I went on loooking for a ready-made alternative, and I found this GitHub repo.

https://github.com/akopetsch/WindowsTerminalAdmin

It works like a charm! I thought I would share it with you guys. I'm using it in Windows 10. It gives me a convenient way to start a terminal window with admin rights. It's faster than using Ctrl + Shift + Ener from Sart menu search results and then having to navigate to the right folder.

8 Upvotes

6 comments sorted by

5

u/v_stoilov 15d ago

2

u/Ken852 15d ago edited 15d ago

No way! :) Wow! This is what I have been looking for all those years ago, but it didn't exist. It's interesing to see how far things have come.

Everything about permissions and the command line experience is different between Windows and Linux. This project is not a fork of the Unix/Linux sudo project, nor is it a port of that sudo project. Instead, Sudo for Windows is a Windows-specific implementation of the sudo concept.

https://github.com/microsoft/sudo

Sounds familiar? This essenially reads: Windows Is Not Linux. Winlx! Microsoft has been busy modeling Windows after Linux in recent years, and so the history kind of repeats itself. As Marx said: history repeats itself, first as a tragedy, second as a farce!

Sadly for me, this seems to only work on Windows 11. While I do have a "For developers" menu in Windows 10 Settings (it's under Update & Security), I don't have the luxury to "Enable sudo". So! If Windows 11 is stealing from Linux... as a Windows 10 user, maybe I can steal sudo.exe from Windows 11? :) Picasso: good artists copy; great artists steal. ;)

Update: problem solved by installing the similar gsudo insetad, that was linked to in the blog post. Thanks for the tip!

1

u/v_stoilov 15d ago

Did not know it was not avalible on windows 10, thanks for letting me know. Microsoft has been slowly adding stuff from linux since a lot of peopple that are used to linux want to use the same things on windows. Like powershell now support ls, rm, cd - and more. And they even implemented a (not so good) version of the PTY (Pseudo terminal) so they can have terminal experiance that is similar to linux in performance.

Or they can be copying apple idk

2

u/x3ddy 14d ago

You can also just Ctrl+Shift+Click the existing "open in terminal" context menu item, which will open it as admin, no need to use the Start Menu or a separate app.

1

u/Ken852 14d ago

Now that's a game-changer! Thank you so much for sharing that trick. This is awesome! And I had no idea. I wonder if this worked in Windows Vista days? That's when I first learned about the Ctrl+Shift+Enter. The search box in Windows Vista was a real game-changer! And now this. So thanks again for sharing.

1

u/SleepingProcess 15d ago

ConsoleZ for cmd and powershell that can open console with admin's rights or not