Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: return code value return codes IntControl(64... Intcontrol(1000...
Unlike the DOS spawn[...] functions, which return the value that was returned by the child process's main() function (or -1 on error), the equivalent Windows API functions (WinExec and LoadModule) return the loaded module instance (or a value <32 on error), so there is no easy way for the calling program to determine the return value from WinMain [the Windows equivalent of main()].
According to the Windows SDK documentation, "The return value from WinMain is not currently used by Windows". It's *possible* for Windows programs to return a value, but in practice they don't.
Despite all this, the Intcontrol(1000...) function in Winbatch might be useful, if you know what the code is you're looking for, and can enter the desired return code first.
However, note that this return code can ONLY be read by DOS batch files, not Winbatch itself or other Windows applications. Make sure you launch Winbatch with a start /w on the command line ala...
start /w abc.exe
a=AskLine("Hello","Enter Return code","13") IntControl(1000,1,0,0,0) exit
:toptop retcode=AskLine("hello", "Enter desired return code", 123) if !IsInt(retcode) then Message(("EEEK", "retcode must be an integer less than 256") if !IsInt(retcode) then goto toptop if retcode<0 || retcode > 255 then Message("EEEEK", "retcode must be an integer less than 256") if retcode<0 || retcode > 255 then goto toptop IntControl(1000, retcode, 0, 0, 0) ;then this retcode can be passed to a DOS batch file.Otherwise, from another winbatch:
RunWait the exe, then use IntControl(64... to retrieve the exit code.
The IntControl(64...) function gets the exit code (also known as the "errorlevel") that was returned by the program that was most-recently run using RunWait (or using RunShell with the @WAIT flag specified). If no program has been run, or if the last-run program was not run in @WAIT mode, this function will return 99999.
If so, See the DOSERROR.WBT and DOSERROR.BAT file in your WINBATCH/SAMPLES subdirectory to show how to return a DOS errorlevel to WinBatch.
If it is a WinApp, launch it via the DOSERROR.BAT file anyway, using the:
START /w mfcobolwhatever.exeThis is the console START command in NT.
Article ID: W12909
Filename: WinBatch and Return Code Values .txt
File Created: 2001:01:02:14:35:50
Last Updated: 2001:01:02:14:35:50