Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I want to know that how to return value(s) from vb.net while execute Batch file,

See my Example:
-----------------
@echo off
cls
echo started...

TestApps.exe "C:\Test\Test1.prj" "Test1.xml"

@if "%ERRORLEVEL%" == "0" goto good
@if "%ERRORLEVEL%" == "-1" goto fail

:fail
    echo Execution Failed
    echo return value = %ERRORLEVEL%
    goto end

:good
    echo Execution succeeded
    echo Return value = %ERRORLEVEL%
    goto end

:end

pause

1. The above code is working fine, because critical message return to the batch file (application will be closed automatically when TestApps.exe critical exception raised),
Ex:
i. Environment.ExitCode = 0
ii. Environment.ExitCode = -1
Note1: If application closed then only return error code to the batch file.

2. But I want to know that how to return warning message code. (In this time TestApps.exe will not be close, because it is warning message.
but I want to access warning message code in batch file without close application.
Note2: How to return value to batch file for each time getting warning message.
Give Idea.

Thanks in Advance.
Posted
Comments
[no name] 18-Aug-14 8:26am    
You don't. Your batch file does not have access to anything your exe is doing while it is running.
PhilLenoir 18-Aug-14 10:43am    
Have you tried setting an environment variable with your VB and using that instead of ERRORLEVEL?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900