Return Value of battingmain.exe

Source: Internet
Author: User

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.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.