I am sorry if I somehow led you to think NSSM is the problem. It's not, PowerBuilder is.
The PROBLEM restated for clarity:
In earlier versions of PowerBuilder I could add code to the application close event that set Message.LongParm to a value and then that value would be accessible to a command file via the ERORLEVEL system variable.
In my current tests with PowerBuilder 12.6, setting Message.LongParm is not working so I Googled the problem and the advice I'm seeing tends more toward using:
// External FUNCTION declaration
SUBROUTINE ExitProcess(ulong uExitCode) LIBRARY "kernel32.dll"
// Powerscript
ExitProcess(<Value>)
But that seems like it terminates the application and any clean up that might have occurred with a normal application exit isn't going to happen. That's not ideal.
My Question is:
Is there any method exiting that will allow me to set that system ERRORLEVEL variable that does not require my causing an abnormal termination to my application?
Or is using the external function ExitProcess really my only option?