1. Home
  2. Windows

Run Bash As Admin From The Context Menu In Windows 10

The Anniversary Update added Bash to Windows 10. The feature in and of itself was the major highlight of the update. This feature is for developers and not the average end user. Bash in Windows 10 makes developing on the Windows platform much easier. It’s also a great way to get developers to upgrade to Windows 10 because you can’t get Bash natively on older versions of Windows. This is a Windows 10 only feature. Bash in Windows 10 is an optional feature so it isn’t integrated like the Command Prompt. If you want to run Bash as admin from the context menu, and be able to open it in any folder location you have to tweak the registry a bit. Here’s how.

Get Bash In Windows 10

Before you can run Bash as admin, you need to make sure you’ve installed it. The process is fairly simple; enable developer mode in the Settings app under For Developers. You will need admin rights to enable it.

After you turn it on, open the Control Panel app and go to Programs>Turn Windows Features On or Off. Select Windows Subsystem for Linux.

Open Command Prompt (with admin rights) and type Bash. Windows 10 will download and install Bash. It can take fifteen to thirty minutes to get it running.

Run Bash As Admin

It’s pretty easy to run Bash as admin but it just isn’t possible from the right-click context menu. You can launch the Bash app from the Windows Search menu or the Start menu but you can’t open it directly in a folder.

Open the Windows Registry. Type ‘regedit’ in the search bar and open it with administrative privileges. Navigate to the following location;

HKEY_CLASSES_ROOT\Directory\shell

Create a new subkey called AdminBash. The new key will have a default string value. Double-click it and change the value to the following.

Run Bash As Admin

Next, in the Bash Admin key you just created, create another key and name it Command. Inside this key, like the previous one, there is a string called Default. Double-click it and change the value to the following.

powershell -c start -verb runas cmd '/c start /D """%V""" bash.exe'

Restart Explorer.exe for good measure. Right-click a folder and select the Run Bash As Admin option from the context menu. Windows PowerShell will open and you will then be prompted to enter your admin password. Once you enter the password correctly, Bash will open.

A Caveat

Bash will not be able to open a folder that has spaces in its name. For example you can use the context menu option to open a folder called ‘Cool-Stuff’ but you cannot use it to open a folder called ‘Cool Stuff’. In Bash, this is usually circumvented by adding quotes around the folder name but the context menu option doesn’t allow that. This hack is therefore limited.

One of our readers Liandri has made this caveat obsolete. The value of the string has been updated in the previous section to the one suggested below in the comment. It was duly tested out and it worked flawlessly. This hack will now work for folder with or without spaces in their name. 

Bash on Windows 10 is available on the Anniversary Update and later builds.

Leave a comment

  • Liandri

    Works with spaces :

    powershell -c start -verb runas cmd ‘/c start /D “””%V””” bash.exe’

    • Thank you! We’ve updated the post and the Caveat section 🙂

      • Chairman of Facebook!, is helping users to start “Work at home” method, that Loads of people have been doing for more than twelve months now. This year alone, I made approximately $36k so far with no more than my computer as well as some spare time, despite that i have a regular nine to 5 job. Even most people newbie in this, can earn $50/per h undoubtedly and the profit may go even higher with time… This is how i started >> http://deliciousurl­.­com//2u

      • M­a­n­y p­e­o­ple desire t­o ha­v­e a go­o­d in­com­e at their, bu­t t­he­y don’t have much idea ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a many w­ays t­o ea­rn great am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a fraud, And so Now I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am making atleast $10000 monthly since 12 months.Its on-line work and also not difficult to do, Even a little boy or girl can do this work and make money on the internet. If you want a happy and rich life then you need to copy and paste this site in browser and then follow instructions to get started right now and make Thousands On-line……….. http://v15­.­uk/UhY2n

      • M­a­n­y p­e­o­ple desire t­o ha­v­e a high in­com­e at h­o­me, bu­t t­he­y do­n’t kno­w ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a many w­ays t­o ea­rn massive am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a s­cam, And so Now I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am earning atleast $10000 on a monthly basis since 12 months.Its an internet based work and also easy to do, Even a little boy or girl can do this work and make money. If you want a happy and wealthy life then you should copy and paste this web site in web browser and then follow instructions to get started right now and make Thousands Using the internet……….. http://ouourl­.­com/4rhb