Windows system uses gitbash to run .bat files
In the daily development of Windows, some children's shoes will use the gitbash command line terminal. Sometimes you need to run your own .bat script file, but you don’t want to open cmd, you want to run the .bat script directly in gitbash (well, actually My colleague said that the cmd terminal is not as good-looking as gitbash), then I will tell you how to run the .bat file in gitbash.
First write your own .bat script in a certain directory of the computer, and then configure the script directory in the system environment variable
Then try to run a script in gitbash, (ngstart as an example) the
system reports an error, this is not a command,
and then try to run ngstart.bat, found that you can run ngstart directly, and found that it can be run directly (well, actually I started It can’t run successfully. After a while, I don’t know why. If you fail to run until here, please continue to look down)
Then Baidu and found that there is a command that can be executed normally.
//cmd.exe /c 命令
cmd.exe /C ngstart
So I thought that instead of typing this command every time, I wrote it as a simple bash script (the script name here is c),
type c ngstart
, everything went well, and then I happily sent the script to the lady
but Miss’s computer just can’t be executed. The script and environment variables have been configured. Every time the script is executed, I
use echo to print multiple times. The cd command in the script cannot be executed. Miss’s computer executes the command on the C drive. But the script is placed on the D drive (my own computer only has a C drive, so there is no switch drive letter), and the commands in the script contain commands such as
cd D:/xxx/xxx, and it is found that gitbash cannot be executed successfully, probably because When gitbash simulates the cmd environment, the expression of the drive letter is different
Gitbash drive letter
So before executing the command, you need to switch the drive letter to the one corresponding to the script command in advance
and then execute xxx.bat (why, I haven’t figured it out yet, researching...)
here, it’s probably fine, my computer Both gitbash and Miss Sister's gitbash can run .bat files