How Do I Run an Executable or External File from within LabVIEW?

Updated Nov 14, 2017

Reported In

Software

  • LabVIEW Full
  • LabVIEW Base

Issue Details

I have an executable (*.exe file) that was created in a different programming environment. This executable runs an application that I would like to call from within my LabVIEW application. How do I launch this executable from within my LabVIEW program? What do I do if the executable requires or can take input options?

Solution

The usual method for calling a *.exe file in LabVIEW is to use the System Exec VI.  The System Exec VI is located in the Communications palette in LabVIEW 7.x or the Connectivity»Libraries & Executables palette in LabVIEW 8.x and higher.
For an example of using the System Exec VI, refer to the Calling System Exec VI in
the <LabVIEW>\examples\comm directory in LabVIEW 2012 and lower, or to the Command Line Execution VI in the  <LabVIEW>\examples\Connectivity\Libraries and Executables directory in LabVIEW 2013 and higher. Or, refer to the LabVIEW Snippet below for a simple way to run the Windows Calculator program from within LabVIEW (minimum of LabVIEW 8.0 required).
 


Figure 1: Windows Calculator Example

Additional Information

Unfortunately, the System Exec VI does not support calling options following the file name.  In order to call the executable with options, here is what you can do instead:
  1. Create a filename.bat file which calls the executable file followed by the desired options (e.g. filename.exe -option1 -option2).
  2. Then, use the LabVIEW System Exec VI to call the filename.bat file and those options will be ported over.
Furthermore, you can also directly call an external file that is not an executable. For example, we will use a file named My Document.txt. You cannot type My Document.txt into the command line input of the System Exec VI. You can, however, type Notepad My Document, and the System Exec VI will open the text file in Notepad.

WAS THIS ARTICLE HELPFUL?

Not Helpful