Example Code

Launch a File Programmatically in its Default Application

Code and Documents

Attachment

 

Overview

This VI illustrates how to launch a file programatically from LabVIEW using the SystemExec VI. Files launched programmatically in this manner will open in their default application from Windows.

 

 

Description

This VI uses Open a Document on Disk VI to programmatically open a file on the disk in its default application. The "Open a Document on Disk" VI is not part of the function palette, but it is available in vi.lib. It is located at <LabVIEW>\vi.lib\Platform\browser.llb\Open a Document on Disk.vi.

 

 

Requirements

LabVIEW 2012 (or compatible)

 

 

Additional Notes or References

When launching a file, be sure to point to its actual destination. Some shortcuts to executables will not work unless you point the to actual location of the executable.

 BD.PNG

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
David_L
Active Participant
Active Participant
on
Knight of NI
Knight of NI
on

This VI is a classic example of a greedy loop.

Theo_Koi
Member
Member
on

None of these seems to work.

 

The "Launch WinFile.vi" throws up an error saying it can't find the file (I have double checked the path is correct).

Actual commands:

cmd /x /c start "C:\" "TXT.txt"

cmd /x /c start "C:\" "CSV.csv"

 

The "Launch File Programmatically_LV2012_NI Verified.vi" doesn't work as expected.

For C:\CSV.csv it actually opens the browser and downloads the file in the Downloads folder. The default app for .csv is Excel.

For C:\XL.xlsx it actually opens the browser and downloads the file in the Downloads folder. The default app for .xlsx is Excel.

For C:\TXT.txt it opens the text file in the browser.

 

Can anyone help. I have spent quite some time looking for a way to simply get LabVIEW to open an Excel file in Excel and none of the methods available out there seems to work.

 

I am Using Windows 7 and LabVIEW 2014 (I also have access to LV2016).

MS Office is installed and activated.

Report generation toolkit is installed and activated, but haven't seen an obvious function that can pop up open an Ecxel file once it has just been generated.