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?
Batch files can be run by typing "start FILENAME. bat". Alternately, type "wine cmd" to run the Windows-Console in the Linux terminal. When in the native Linux shell, the batch files can be executed by typing "wine cmd.exe /c FILENAME.
cmd and . bat file processing is that in a . cmd file the ERRORLEVEL variable changes even on a successful command that is affected by Command Extensions (when Command Extensions are enabled), whereas in . bat files the ERRORLEVEL variable changes only upon errors.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With