In short: Seems like ExitCode is not always reliable retrieved with %ERRORLEVEL% if Project is not a console project.
Long version:
I'm testing simple example of how ExitCode works. The problem is that I can't reliable retrieve it with %ERRORLEVEL%, when not running in batch file.
When executing example project in batch file, it works OK, always shows correct ExitCode as %ERRORLEVEL%. This is batch file - that always works:
project1.exe
echo %ERRORLEVEL%
echo always show correct ExitCode as set in project1.exe.
BUT:
When I try to execute the same project1.exe from cmd line, without batch file, it doesn't reliable returns ExitCode with echo %ERRORLEVEL%.
This is how I run it without batch file:
This is simple VLC Forms project:
program Project1;
uses
Vcl.Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
ExitCode := 2;
// Application.MainFormOnTaskbar := True;
// Application.CreateForm(TForm1, Form1);
// Application.Run;
end.
Then, I tried to do the same with Console project and in this case %ERRORLEVEL% always works correct - show correct ExitCode, with and without batch file.
So, am I missing something really obvious? Is non-console project the problem here?