From http://hi.baidu.com/toening/blog/item/7f2c7009d7ac439c0a7b8287.html
Recently, we need to use a batch file to execute three EXE files in sequence,
@ Echo off
1. exe
2. exe
3. exe
The requirement is that if any EXE file cannot be correctly executed, the subsequent exe will not run.
This involves the issue of the returned values of the EXE, which is used to determine whether the EXE is correctly executed.
EXE is a console program written in VC 2005. The returned value is the nretcode defined in the main function. 0 indicates that the execution is successful, and 1 indicates that there is an error.
In batch processing, the returned value can be obtained through errorlevel.
In this case, OK.
Some time ago, in a project, a bat called several EXE files, while bat was triggered by cybermation. In addition, to accept the command line argument, I studied it and found the answer:
@ Echo off
Set Path = % 1
Set filename = % 2
1. EXE % PATH % filename %
If % errorlevel % = 0 (2.exe % filename %) else (Goto: exceptionend)
Exit 0
: Predictionend
Exit 1
% 1 is the placeholder of the first input parameter, % 2 is the second, and so on.
Use name. Bat "D:/" "1.txt" to trigger bat.