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 Linux

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 Explorer

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.

Soufiane – Easytutorial.com