Aha, OK! Looking at source code, the cryptic “Failed to execute : 740” is from FPC implementation of TProcess on Windows (fcl-process/src/win/process.inc
). They do Raise EProcess.CreateFmt(SErrCannotExecute,[FCommandLine,GetLastError]);
and
-
FCommandLine
is empty (I guess becauseTProcess.CommandLine
got deprecated some time ago, in favor ofTProcess.Parameters
list (and from CGE we indeed use new, non-deprecatedTProcess.Parameters
)) -
and for some reason they just show an error number, not String message (I think
SysErrorMessage
would give the right message).
So we end up with cryptic “Failed to execute : 740”. Fixing this would require a fix from FPC side (do you want to submit a report to them?), to use WCommandLine
and SysErrorMessage
.
Looking at Windows codes, 740 is
ERROR_ELEVATION_REQUIRED
740 (0x2E4)
The requested operation requires elevation.
( System Error Codes (500-999) (WinError.h) - Win32 apps | Microsoft Learn ). It seems we didn’t have permissions to execute Lazarus. So this matches your finding. So error message was right, albeit cryptic.
I would recommend that, instead of “elevating” the CGE editor privileges, you fix the Lazarus privileges. For some reason, your Lazarus can be executed only by administrator, at least the WinAPI used by TProcess behaves like it. For security, it’s better to not run “normal” applications with admin privileges.