3

I have successfully added the Bash on Ubuntu prompt to the context menu by adding the following registry keys

[HKEY_CLASSES_ROOT\Directory\shell\bash]
@="Bash Here"
[HKEY_CLASSES_ROOT\Directory\shell\bash\command]
@="C:\\Windows\\System32\\bash.exe"

Now, the above solution has two major issues one issue which I do not know how to address.

The problem is that the path to which it launches is actually that of the parent directory, not the one being right clicked.

I tried including additional arguments to the launch command, however, that results in the prompt being closed immediately before even having a chance to read any error information.

The default command from the shortcut C:\Windows\System32\bash.exe ~ does indeed work and put me in /home/user/

UPDATE: It seems that executing C:\Windows\System32\bash.exe uses a set of settings stored under [HKEY_CURRENT_USER\Console\%SystemRoot%_system32_bash.exe] as well as some (colors for instance) from the default location [HKEY_CURRENT_USER\Console], so once those settings are saved they do successfully reload. Whereas, the shortcut created on install seems to use the settings assigned to cmd.exe (to be confirmed)

UPDATE 2: Please do not offer solutions involving launching bash.exe from inside cmd.exe

1
  • To anyone who arrived to this question when searching for the path to add to Windows Path variable for bash.exe, it's c:\Windows\Sysnative. It's a tricky one. – Artem Russakovskii Jan 18 '17 at 7:42
2

You can find a step-by-step tutorial how to do this on this page: http://winaero.com/blog/add-bash-to-the-folder-context-menu-in-windows-10/

Additionally they offer ready-to-use registry files. I tested the registry files and they work on my Win10 x64 system.

2
2

An easy fix to this is to run through cmd. This command sets the current working directory to the selected folder and then launches bash.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Bash]
@="Bash Here"

[HKEY_CLASSES_ROOT\Directory\shell\Bash\command]
@="C:\\Windows\\System32\\cmd.exe /k cd %1 && C:\\windows\\system32\\bash.exe"

Tested and working, just save the above code into a text file and rename the extension to .reg

If you want to exit after instead of dropping back into CMD just type && exit at the end of the command

4
  • 1
    If you want to exit afterwards you could also change the /k to /c. – GuitarPicker Aug 5 '16 at 17:07
  • This does indeed work, however, it launches off of the cmd.exe settings (obviously) and uses the same icon in the upper left, any way around this? – Constantine Aug 6 '16 at 3:38
  • Does not work for mapped drives. – Drew Chapin Sep 6 '17 at 12:17
  • Do you see the mapped network drives in /mnt ? Have a look at superuser.com/a/1136369/624775 it appears network drives have only just been included. – mt025 Sep 7 '17 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.