Display Script Execution in Shell Command While Redirect Output to LabVIEW

Updated Dec 23, 2022

Reported In

Software

  • LabVIEW

Issue Details

The VI System Exec is used to execute code in form of command line such as you can do from the Windows "Command Prompt" and also known as "CMD".

LabVIEW can run a script executed by this Windows "Command Prompt".

The behavior of the vi can be:
  • If "wait until completion?" is set to "True"
  • wait until completion =
Result of this script is redirected to LabVIEW in the "Standard Output" terminal of "System Exec". If the terminal "run minimized?" is set to "False" such as the example, the console will be displayed but empty
  • If "wait until completion?" is set to "False"
wait until completion =
The script is executed asynchronously and LabVIEW proceed his own execution without waiting the completion of the command. In that case, you can observe the execution on the "Command Prompt" Window but the "Standard Output" terminal will be empty.

Is there any way to see the execution in the "Command Prompt" Window and also get the Output command to process the result in LabVIEW?
 

Solution

This is due to limitation of the Windows "Command Prompt". When a Windows process is launched, there is a redirection option of the output stream that can be defined. In that case, the parent process will be able to get that output stream to process that data. For the "Command Prompt" Windows, if that redirection option is provided, the console will not display the output result. This is the effect of the "wait until completion?" terminal.
For further details :ProcessStartInfo Class

There are two workarround:
  1. JKI provides a librairy to redirect to LabVEW the standart output while visualizing the execution in a Window. JKI .NET System Exec
  2. Powershell don't have the exact same behavior of the Windows "Command Prompt". It allows to execute a script and also pipe the output to a ressource such as a file to be later on displayed in LabVIEW. The file attached below gives a example on how to do it in practice (require LabVIEW 2020).