Chiel
Chiel

Reputation: 682

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/"

Upvotes: 2

Views: 1646

Answers (1)

pjh
pjh

Reputation: 8064

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.

Upvotes: 3

Related Questions