LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to run a shortcut with "system exec"

Hello,
Using "start shortcut-name" can open the shortcut related software in dos console window. But if "start shortcut-name" is used in "system exec", it displays "memory is full"; if "cmd /k start \file path\shortcut-name", only the dos window displays a short time, and the needed software is not opened.

Any suggestion? Thanks!
0 Kudos
Message 1 of 7
(4,835 Views)
I needed to launch a third party application recently to run along side my application.

The code I used is shown in the attached jpg. Ignore the function following the system exec, it just logs errors if they occur.

I just copied the command line that was displayed when I did a right-click >>> properties on the the shortcut.

The copied string is what you see in my example. The other booleans are set such that the application shows it GUI and the system exec returns after launching.

I hope this helps,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 7
(4,829 Views)
The syntax of the start command is tricky and depends of Windows flavor.
If the target path contains spaces it must be enclosed in quotes.
I'm on Win98 now and the command
start "c:\my program.lnk"
works.

However, on Win 2K/XP I think it must be
start "" "c:\my program.lnk"
because the first argument with quotes is the window title.


LabVIEW, C'est LabVIEW

0 Kudos
Message 3 of 7
(4,816 Views)
Hello Ben and Jean-Pierre Drolet,
Thank you for your reply!
The reason using a shortcut in "system exec" is that I want to start a modem connection by the program. If I right click the shortcut, only "Target location: network connection", and there is no exe file related to this shortcut.

Since there is no empty space in my folder name, "" seems not needed in my xp computer.

I have checked that "cmd /k start d:\startmodem" can start the connection if startmodem is the shortcut name of the network connection. The only problem is that I need manually close the dos window. If "/c" is used instead of "/k",
the connection window doesn't appear, only the dos window appears a short time.
0 Kudos
Message 4 of 7
(4,803 Views)
It might help to put the command in a batch file and execute the file.
In the command file, put a "pause" command at the end to see eventual error message.
Don't forget the *.lnk extension.

What is the actual command you are trying to execute?


LabVIEW, C'est LabVIEW

Message 5 of 7
(4,791 Views)
Hello Jean-Pierre Drolet,
The actural command is to start the modem network connection.
If the related file of the shortcut is an exe file, the "system exec" can work well. For the network connection which has no specified file related, I have to use "cmd /k start startmodem".
I tried to put the shortcut in a bat file. It seems that they are similar. The pause used in the bat file didn't display the reason. Thank you anyway!
0 Kudos
Message 6 of 7
(4,761 Views)
Have you tried editing the properties of the batch file to force it to "Close on exit" (right-click on the batch file and select Properties » Program)? This creates a *.pif file in the same directory that Windows uses to control the window behavior when the batch file is run. See KB 18T91CVJ: After Running a Batch File with the System Exec VI, the Command Window Remains Open
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 7 of 7
(4,747 Views)