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

Constantine
  • 131
  • 4
  • 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 07:42

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,280
  • 2
  • 21
  • 39
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.

  • 4
    Please include the core of the included link in your answer. That way, people will be able to use it even if the link goes down for some reason. [Here's a meta discussion about why you should include the important details in your answer](https://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers/8259#8259) – Cas Oct 07 '16 at 10:38
  • The instructions in that blog post amount to the previous answer with the same inherent issues. – Constantine Oct 07 '16 at 18:41