How to run .bat or .cmd files in bash for Windows 10

I am trying to run glcoud.cmd from a bash shell installed on Windows 10. Glcoud is recognized in the cmd prompt, but not recognized in "bash for Windows 10".

based on this stream, I created a .bashrc file with this entry ( Can I use gcloud in Git bash on Windows? ):

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

glcoud.cmd is a Windows command line script. The path seems to be recognized by bash because when I run gcloud.cmd it returns

/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 have also tried the following commands because CYGWIN seems to automatically recognize bat files.

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

      

All of the above commands return:

There is no 'cmd' command, you mean: 'cmp' command from 'diffutils' package (main) 'wmd' command from 'wml' package (universe) 'dcmd' command from 'devscripts' package (main) 'mcd' command 'from package' mtools' (main) Command "vcmd" from package "core-network-daemon" (universe) Command 'jcmd' from package 'openjdk-7-jdk' (main) Command 'tcmd' from package 'tcm' (universe) Command 'cm' from package 'config-manager' (universe) Command 'cme' from package libconfig-model-perl '(universe) Command' amd 'from package' am-utils' (universe) Command 'icmd' from package 'renameutils' (universe) Command 'mmd' from package 'mtools' (main) Command "qcmd" from package "renameutils "(universe)

How do I execute windows commands in bash?

thank

Floor

+3


source to share


2 answers


Sorry to post this as an answer, but I can't comment yet. I thought maybe you could have a batch file that calls bash scripts and then as soon as they exit it starts beating files and then runs more bash scripts? You can split your code too ... Just an idea.



+1


source


You need to provide the full path to cmd.exe.

I 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

      

+1


source







All Articles