03-13-2024 03:21 AM
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?
03-13-2024 04:07 AM
03-13-2024 05:41 AM - edited 03-13-2024 05:45 AM
You need cmd /c at beginning and full path of exe encapsuled with "..." :
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.
03-13-2024 06:16 AM
@Walker34 wrote:
You need cmd /c at beginning and full path of exe encapsuled with "..." :
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.
03-13-2024 08:28 PM
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
03-13-2024 08:29 PM
I tried as you said but it still doesn't work
03-14-2024 04:17 AM
@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.