- Follow the steps in Execute Command Line Arguments from LabVIEW to set up and configure your System Exec VI. If you need to pass arguments that are placed following the file name, copy the command as it would look when called with the command prompt.
- Input the full file path of the executable in the command line. Enter the entire command as you would type it at the DOS prompt, including all parameters.
- If the executable directory is present in the Windows PATH environment variable, you can run the executable by using its filename as this string input (e.g., application_name.exe).
- If the string contains spaces, surround the string with "" (quotation marks).
- Input the file path to the folder of the executable into the working directory.
In the snippet below, the System Exec VI is used to run the Windows Notepad program from within LabVIEW.
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram
Considerations
- An alternative when sending arguments to the System Exec VI is to use a batch file by following these steps:
- Create a
filename.bat
file which calls the executable file followed by the desired options (e.g. filename.exe -option1 -option2
). - Then, use the LabVIEW System Exec VI to call the
filename.bat
file.
- If you are using LabVIEW 32-bit and trying to call an executable that is located in the C:\Windows\System32 folder, you might see, that the .exe cannot be opened. The reason here is, that you cannot access 64-bit executables via the 32-bit LabVIEW environment.
- To run those .exe files, create a batch file, specify the whole path of the .exe and replace System32 with sysnative. This is a special folder that is invisible in the Windows Explorer, but it is used as a File System Redirector to access the 64-bit System32-folder from 64-bit applications or scripts.
- Here is an example of what a batch file includes that calls, for example, the ie4uinit.exe and hands over the parameter -show:
- C:\Windows\sysnative\ie4uinit.exe -show
- Refer to [External] Sysnative folder in Windows 64-bit explained to understand the sysnative folder in more detail.
- If you are using LabVIEW 64-bit, then you do not have to change the path from C:\Windows\System32 to C:\Windows\sysnative.
- Refer to the Command Line Execution VI in the labview\examples\Connectivity\Libraries and Executables directory for an example of using the System Exec VI.
- The standard input terminal allows you to redirect input to the program that you are running. For example, if you were running a batch file with a "pause" statement, you could input an end-of-line through the standard input terminal to simulate pressing "Enter" on the keyboard. Please note that the standard input is ignored when the wait until completion input is false.