I know this is possible by using the GetExitCodeProcess API, the problem with it is that it just catches the code of the ending command... for example, a batch file with this code:
The function catches the errorlevel correctly, but if I add "echo errorlev = %ERRORLEVEL%" the GetExitCodeProcess returns a 0 as the last line isn't generating any error...Code:@echo off copy c:\dummy.jpeg c:\
I've tried catching the exit code doing a loop this way:
vb Code:
ProcessId = Shell("c:\a.bat", 1) hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId) Do Call GetExitCodeProcess(hProcess, exitCode) DoEvents Loop While exitCode <> 0 CloseHandle hProcess
But it only gets the exitCode = 259, which is the corresponding one to the process still being active...
Is this possible without having to resort to something like "echo %ERRORLEVEL% > errors.txt"?




Reply With Quote