Search code examples
windowsbashbatch-filegcloud

how to run .bat or .cmd files from Bash for Windows 10


gcloud.cmd is a Windows command-line script. I am trying to run it from the Bash shell installed on Windows 10. It is recognized by the CMD prompt, but not by “Bash for Windows 10”.

Based on this thread I created a .bashrc file with this entry:

PATH=$PATH:/mnt/c/Users/username/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin

It seems that Bash now finds the file because when I run gcloud.cmd it shows:

/mnt/c/Users/***/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud.cmd: line 1: @echo: command not found
/mnt/c/Users/***/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud.cmd: line 2: rem: command not found
/mnt/c/Users/***/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud.cmd: line 7: syntax error near unexpected token `newline'
/mnt/c/Users/***/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud.cmd: line 7: `rem <cloud-sdk-cmd-preamble>'

I also tried the following commands because Cygwin seems to recognize .bat files automatically:

cmd.exe gcloud.cmd
cmd gcloud.cmd 
cmd gcloud
cmd /c gcloud
cmd /c glcoud.cmd

All of the above commands show:

No command 'cmd' found, did you mean: (…)

How do I run Windows Batch commands from Bash?


Solution

  • Sorry to post this as an answer but I cannot yet comment. I was thinking that maybe you could have a batch file that calls bash scripts, then once they exit, it starts to bat files, then starts more bash scripts? You could split your code in too... Just an idea.