Calling a Windows Shortcut from LabVIEW

Updated Aug 17, 2023

Reported In

Software

  • LabVIEW

Operating System

  • Windows

Issue Details

I need to call an application from LabVIEW, but I only know the location of the shortcut to the application (not the actual application). How can I call the shortcut to the application from LabVIEW?

Solution

Below is a VI that utilizes the System Exec VI  to run an application at a specific file path. 
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.

Additional Information

The input command syntax will depend on your system and the shortcut location. Listed below is the syntax for the most common versions of Windows:

Windows 95/98/ME:

Use the System Exec VI, which is located in the Connectivity»Libraries & Executables palette. The Command Line input has the following form in the case of using a shortcut: 

start <path to the shortcut in MS-DOS format>

For instance, if I had a shortcut on my desktop called short.lnk, then the command to execute would be:

start c:\windows\desktop\short.lnk

This will bring up a command window that will then launch the application, to which the shortcut points. If you don't want the command window to appear, then you can set the Run Minimized input on the System Exec VI to True.

Windows NT/2000/XP/Vista/7:

Use the System Exec VI, which is located in the Connectivity»Libraries & Executables palette. For the Command Line input, enter cmd. For the Standard Input input, enter start <path to the shortcut in MS-DOS format>, followed by pressing Enter. As mentioned above, you can set Run Minimized to True and the command window will not appear.

Note: Right clicking the shortcut and selecting Open File Location will show you where the original file exists. With the original location, you can call the application directly from LabVIEW.