To handle the return value of the console app execution at the command line

Source: Internet
Author: User

Handles the return value of the console app execution at the command line. Create a new Win32 Console project: The Comparedirs code is as follows (VS2008 code generated by default):
1 //CompareDirs.cpp: Defines the entry point of the console application. 2 //  3   4#include"stdafx.h"  5#include"CompareDirs.h"  6   7 #ifdef _DEBUG8 #defineNew Debug_new9 #endif  Ten    One    A //the only Application object -    - CWinApp Theapp;  the    - using namespacestd;  -    - int_tmain (intARGC, tchar* argv[], tchar*envp[]) + {   -     intnRetCode =0;  +    A     //initializing MFC and displaying errors on Failure at     if(! AfxWinInit (:: GetModuleHandle (NULL), NULL,:: GetCommandLine (),0))   -     {   -         //TODO: Change the error code to suit your needs -_tprintf (_t ("Error: MFC initialization failed \ n"));  -nRetCode =1;  -     }   in     Else   -     {   to         //TODO: Write code here for the behavior of the application.  +     }   -    the     returnnRetCode;  *}
The return value of the CompareDirs.exe to be processed from the command line. Looked up on the internet, there is processing is not correct, there are processing LOG instead of the return value. Modify the different return values of the CompareDirs.exe to verify the output of the batch program execution.
@echo off  comparedirs  @if "%errorlevel%" = = "0" goto good    : Fail      echo (execution Failed)      Echo ( return value =%errorlevel%)      goto end    : Good      Echo (execution succeeded)      echo (return value =%errorlevel %)      goto end    : End    Pause  

To handle the return value of the console app execution at the command line

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.