Reputation: 5350
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?
Upvotes: 7
Views: 17724
Reputation: 71
You need to specify the full path to cmd.exe.
I have added the following to my ~/.bash_aliases:
alias cmd='/mnt/c/Windows/System32/cmd.exe /c'
with this you can run *.bat files with:
$ cmd ./test.bat
Upvotes: 7
Reputation: 64
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.
Upvotes: 2