Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start bash in certain directory from Windows

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/"
like image 374
Chiel Avatar asked Dec 20 '25 03:12

Chiel


1 Answers

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.

like image 101
pjh Avatar answered Dec 22 '25 22:12

pjh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!