Run an Executable Programmatically with LabWindows™/CVI™

Updated Jun 20, 2023



  • LabWindows/CVI

In LabWindows/CVI, you can programmatically call executables (*.exe) files or applications using system() or LaunchExecutableEx() functions. 

This article goes through the differences between both methods and explains how to use them and has an example on how to run commands using cmd.exe.

This method starts running a program and waits for it to exit. The executable can be an MS-DOS or Windows executable, including *.exe, *.com, *.bat, and *.pif files. This function does not return until the command terminates. User keyboard and mouse events are ignored until the command exits. 

If you do not want to wait for the program to exit, use LaunchExecutable() or LaunchExecutableEx() in the Utility Library.

Performs the same operation as LaunchExecutable  with the following extended features:
  • Under Windows, you can specify how the Windows application displays.
  • LaunchExecutableEx returns a handle to the executable that can show whether the executable is still running and that you can use to terminate the executable.
This function starts running a program and returns without waiting for the program to exit. The executable can be a DOS or Windows executable, including *.exe, *.com, *.bat, and *.pif files.

Execute a Command Built into Cmd.exe
If you need to execute a command built into cmd.exe with any of the previously mentioned methods, such as copy or dir, you can call the function with the following command:

cmd.exe /c command args

where command is the command you want to execute. For example, the following function call copies file.tmp from the temp directory to the tmp directory:

system ("cmd.exe /c copy c:\\temp\\file.tmp c:\\tmp");


LaunchExecutable("cmd.exe /c copy c:\\temp\\file.tmp c:\\tmp");

Next Steps

For more information on commands and their syntax, consult your OS manufacturer's documentation: Windows Terminal command-line arguments - Microsoft Docs.