>Ed,
>
>I'm using your api_apprun to run a command that returns and errors as a string returned to the console. I've changed the apirun.iccommandline to include " > error.txt". As soon as I do, nothing happens. The return result remains true, but the command is no longer executed. Nor is any error.txt file produced.
>
>As soon as I take the " > error.txt" out, then it works fine again. But, of course, now I can't read any possible error conditions.
I suspect that error.txt -is- produced; you're porting the output of the STDOUT port, not STDERR, to error.txt. That should hold anything written to the console under normal circumstances. But a write to STDERR may not be routed via STDOUT, so the simple > redirection may not be adequate. One of the structures in the API call can be used to redirect any of the three standard ports (STDIN, STDOUT and STDERR) to a file handle opened by the parent app - you'd have to hack the code, or wait until I make that particular hack; the new version should be posted in a couple of days anyway to permit priority control, impersonation and remoted execution; I found a bug in my CreateRemoteProcess() code in WhilFest that needs to be fixed before the release.
A DOS app that runs returns success to API_APPRUN; however, it reports its success/failure through a termination code. This is a numeric code that used to drive the DOS command window ERRORLEVEL. You can retrieve that error code from a launched app via the CheckProcessExitCode() method; it will return a 259 if the process is still running, a 0 if it terminated normally, and any other numeric value represents an error condition reported at termination by the DOS application. If you use LaunchAppAndWait() to run the app; you can grab the termination code any time after the return from LaunchAppAndWait() by calling the CheckProcessExitCode() method until (1) you release the object, or (2) you perform a subsequent launch operation from the same object. If you use LaunchApp to run asynchronously, you can use CheckProcessExitCode() to poll for termination as well as to retrieve the termination code; once the app stops running, the value remains static until one of the preceding actions are taken.