LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Run file .exe with cmd labview

I need to run application in a folder with system exec in labview, I have tried a few ways but it doesn't work.
I run the command prompt as follows:
cd C:\Users\ANH VU\Desktop\GPPD -> enter
a.exe -> enter -> file run success

I don't know how to do it with system exec in labview so i created a bat file as below then I used system exec to run it but it didn't work
@echo off
cd /d "C:\Users\ANH VU\Desktop\GPPD"
a.exe
Can anyone give me some advice?

0 Kudos
Message 1 of 7
(725 Views)

Hi Vu,

 

why don't you call "C:\Users\ANH VU\Desktop\GPPD\a.exe" directly using SysExec?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(698 Views)

You need cmd /c at beginning and full path of exe encapsuled with "..." :

 

Walker34_0-1710326586600.png

 

 

note : all is explained in help:

command line indicates the command LabVIEW calls to run a program.

If the executable is not in a directory listed in the PATH environment variable, the command line must contain the full path to the executable. (Windows) To use a command that must be executed directly from a command prompt window, insert cmd /c before the command.

0 Kudos
Message 3 of 7
(670 Views)

@Walker34 wrote:

You need cmd /c at beginning and full path of exe encapsuled with "..." :

 

Walker34_0-1710326586600.png

 

 

note : all is explained in help:

command line indicates the command LabVIEW calls to run a program.

If the executable is not in a directory listed in the PATH environment variable, the command line must contain the full path to the executable. (Windows) To use a command that must be executed directly from a command prompt window, insert cmd /c before the command.


Actually it is a little more involved. You don't really need to run a normal Windows executable through the cmd.exe utility in most cases. And you don't need to add the entire path to the executable name if it is located in a location listed in the PATH environment variable. You also can add a directory which the executable will use as its initial current working directory in the parameter "working directory". LabVIEW will instantiate the executable specified in the command line and initialize its working directory according to that parameter.

 

Only if you want to do more fancy things, such as just specifying the program name without exe file ending, more complex parameter passing to the executable or executing command line commands such as del, executing batch files or use environment variable expansion and similar that are not part of the Windows NT OS, but rather implemented in the Windows Command Line utility, you do need to invoke cmd.exe in the System Exec.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 7
(661 Views)

I have tried those basic ways to run it but it doesn't work for me, my program must point directly to the path containing its directory for it to work. So when running cmd, I have to cd to the directory first and then type the program name

0 Kudos
Message 5 of 7
(622 Views)

I tried as you said but it still doesn't work

0 Kudos
Message 6 of 7
(621 Views)

@Vu_Anh wrote:

I tried as you said but it still doesn't work


"It doesn't work" is a phenomenally helpful error description! 🤔

Does the application not start up? Cause any error messages, or some function doesn't work? Does the PC burst in flames or start playing some crazy sound? 😃

 

For all practical purposes specifying the working directory in the extra parameter together with the full absolute path to the executable should be pretty much equivalent to your batch script. And the full absolute path would be only required if the directory in which the executable is located is not listed in the PATH environment variable.

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 7
(587 Views)