gitbash run .bat

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
Insert picture description here

Insert picture description here
Then try to run a script in gitbash, (ngstart as an example) the
Insert picture description here
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)
Insert picture description here
Then Baidu and found that there is a command that can be executed normally.

//cmd.exe /c 命令
cmd.exe /C ngstart

Insert picture description here
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),
Insert picture description here
type c ngstart
Insert picture description here
, 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
Insert picture description here
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

Insert picture description here
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...)
Insert picture description here
here, it’s probably fine, my computer Both gitbash and Miss Sister's gitbash can run .bat files

Guess you like

Origin blog.csdn.net/pjw1217/article/details/110623514
bat
Recommended