2

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

2 Answers2

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

mt025
  • 3,506
1

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.