Run Program (As) STDOUT, STDERR capture variables
Posted: Thu Oct 22, 2015 7:30 pm
The Run Program command, either standard or elevated, currently captures the launched process's exit code in a variable provided by the user. But Run Program would be very efficient if it also had place holders for two user defined variables to capture the process's STDOUT and STDERR streams. Currently, one must reconfigure the command line argument to include a redirection to a local file and after the Run Program command returns, one must open and read that file to acquire the process's STDOUT / STDERR output. However, this does not always work correctly.
The Run Program As (in this example) inputs to capture the output from running the Windows utility fsutil.exe (to enable the 8.3 name generation ability of drive C:) would be:
Program = cmd.exe;
Command line argument = /c fsutil.exe 8dot3name set C: 0>{SOME_LOCAL_FILE}.
Wait for program exit checked.
This fails with an exit code of 1 (Incorrect program) but running from a Windows Admin Command Prompt:
fsutil.exe 8dot3name set C: 0>{SOME_LOCAL_FILE} returns exit code 0 with data returned on STDOUT.
If I remove the file redirection from the Run Program As command line argument (i.e. /c fsutil.exe 8dot3name set C: 0), it returns error code 0, but I have no way to read the output from fsutil's STDOUT stream.
The Run Program As (in this example) inputs to capture the output from running the Windows utility fsutil.exe (to enable the 8.3 name generation ability of drive C:) would be:
Program = cmd.exe;
Command line argument = /c fsutil.exe 8dot3name set C: 0>{SOME_LOCAL_FILE}.
Wait for program exit checked.
This fails with an exit code of 1 (Incorrect program) but running from a Windows Admin Command Prompt:
fsutil.exe 8dot3name set C: 0>{SOME_LOCAL_FILE} returns exit code 0 with data returned on STDOUT.
If I remove the file redirection from the Run Program As command line argument (i.e. /c fsutil.exe 8dot3name set C: 0), it returns error code 0, but I have no way to read the output from fsutil's STDOUT stream.