open add bash as admin linux ubuntu context menu windows easy tutorial

Open Bash as Admin from Context Menu on Windows 10

Published by Soufiane Sabiri | Categories : Computers - Tips & Tricks - Computers - Windows 10

Are you a developer and often use Bash on Windows 10?

Do you want to access folders from Bash easily from the context menu?

The Bash was added to Windows 10 in the Anniversary Update. This feature allowed developers and power users to benefit from the tools and commands that Linux (ubuntu) provide. This major step took place in order to encourage developers and Linux enthusiasts to upgrade or migrate to Windows 10 since you can’t get Bash natively on older versions of Windows.

Bash in Windows 10 is an optional feature so it isn’t built-in like the Command Prompt. If you wish to run Bash as admin from the context menu, and be capable to open it in any folder you should do a Registry trick which you will discover in this tutorial.

1. How to Enable Bash on Windows 10

Before you may run Bash as admin, you have to be sure you’ve installed it. The method is pretty easy; allow developer mode within the Settings app under For Developers. You’ll need admin rights to allow it.

After you turn it on, open the “Control Panel” > “Programs and features” and click on “Turn Windows features on or off“.

open add bash as admin linux ubuntu context menu windows 1 programs and features
open add bash as admin linux ubuntu context menu windows 2 turn windows features on or off

Check in the list the option “Windows Subsystem for Linux“. Click “OK“.

open add bash as admin linux ubuntu context menu windows 3 windows subsystem for

Now go to Microsoft Store and search for Ubuntu. Click “Get“, then “Install“.

open add bash as admin linux ubuntu context menu windows 4
open add bash as admin linux ubuntu context menu windows 5
open add bash as admin linux ubuntu context menu windows 6

Launch Ubuntu from the Start menu.

open add bash as admin linux ubuntu context menu windows 7

It will install itself automatically, just enter your desired username and password.

open add bash as admin linux ubuntu context menu windows 8 installation installing

Now that we have installed Bash, let’s see how we can enable accessing it from the context menu on any folder on your system.

2. How to Edit Registry to Run Bash as Admin

It’s fairly straightforward to run Bash as admin however it simply isn’t doable from the right-click context menu. You possibly can launch the Bash app from the Windows Search menu or the Start menu however you can’t open it immediately in a folder.

Open the Registry Editor by typing regedit in Run (Windows+R)

enable hibernation windows 7 regedit

Use the arrows on the left side of keys to navigate to this path in the Registry Editor.

HKEY_CLASSES_ROOT\Directory\shell

Create a brand new key under the key “shell” named “AdminBash“. The brand new key may have a default string worth.

open add bash as admin linux ubuntu context menu windows 9 regedit registry

Select the newly created key “AdminBash” and double-click on the “(Default)” string value and give it the following value:

Run Bash As Admin

You may give it any name you want, just make sure it’s clear that it’s clearly describing its primary function.

open add bash as admin linux ubuntu context menu windows 10 regedit registry editor

Subsequent, within the AdminBash key you created, create another key and title it “command“. Inside this key, just like the earlier one, there’s a string referred to as “(Default)“. Double-click it and alter the value of it to the following:

powershell -c start -verb runas cmd '/c start /D """%V""" bash.exe'
open add bash as admin linux ubuntu context menu windows 11 registry adminbash
open add bash as admin linux ubuntu context menu windows 12 registry

Do the same in this path to enable the context menu when you right-click on empty space in an actual folder:

HKEY_CLASSES_ROOT\Directory\Background\shell\
open add bash as admin linux ubuntu context menu windows 14 rightclick registry

Restart explorer.exe for good measure.

To do this open the Task Manager using CTRL+SHIFT+ESC.

Choose explorer.exe from Details and click “End task“.

open add bash as admin linux ubuntu context menu windows 16

Launch it again by going to “File” > “Run new task“.

Type explorer in the window “Create new task” and click “OK“.

open add bash as admin linux ubuntu context menu windows 17

Right-click on a folder and choose “Run Bash Ad Admin“. You can also right-click inside a folder…

open add bash as admin linux ubuntu context menu windows 13

There you have it!

I hope this tutorial helped you improve your productivity and earn some time using Bash on Windows 10!

Feel free to share this tutorial with your friends, sharing is caring.


Related tutorials:


Be the first to leave a comment !

Leave a comment

xD oO ^_^ =] =) ;-( ;) :| :woot: :whistle: :sleep: :sick: :police: :p :o :ninja: :mm: :love: :lol: :kiss: :hmm: :evil: :bandit: :angel: :alien: :D :) :( 8)