3

I am trying to start Bash.exe in the "/mnt" directory.

The following command properly starts bash:

C:\Windows\Sysnative\bash.exe 

I have the following .bat file:

C:\Windows\Sysnative\bash.exe -c "cd /mnt/" 

Unfortunately, this does not do anything. The same applies to:

C:\Windows\Sysnative\bash.exe --cd "/mnt/" 
5
  • Disclaimer: even though there are very similar posts, this is not a duplicate. Commented Oct 5, 2018 at 13:27
  • I don't use bash.exe, but, have you tried "\" ? Commented Oct 5, 2018 at 14:15
  • The formatting of the slashes is already correct in this example. If it were not, it should give an error that it can not find the path. Commented Oct 5, 2018 at 14:28
  • Do you have a .bash_profile or .bashrc file in your home directory? Commented Oct 5, 2018 at 14:35
  • No. I do not have a .bash_profile or .bashrc file in my /home directory, nor in any of it's subdirectories. Commented Oct 5, 2018 at 14:40

1 Answer 1

4

Try:

C:\Windows\Sysnative\bash.exe -c "cd /mnt/ ; exec bash" 

That starts a Bash process that cds to '/mnt/' and then replaces itself with a new (interactive) Bash process that is running in the '/mnt' directory.

The code above is only lightly tested, and may or may not meet your requirements. For alternatives see run bash command in new shell and stay in new shell after this command executes and "Linked" pages from that.

Sign up to request clarification or add additional context in comments.

1 Comment

This fully meets my requirements. I tested it and it works perfect. Great work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.