LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do you change the directory of system exec after it has ran once in the current vi

Hi all,

 

Attached is the sub vi that i am running in my main application.  I run it twice and change the directory of the file to run.  It appears that after i run this vi that i cant change the directory and it tries to run a file from the incorrect directory.  Does anyone have any advice on how to fix this issue?



-Matt
0 Kudos
Message 1 of 9
(4,644 Views)
What OS? The operation of the system exec function can vary with version of Windows.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 9
(4,619 Views)
It's a windows 7 system.


-Matt
0 Kudos
Message 3 of 9
(4,578 Views)
You could put the command to run the executable in a batch file that sets the directory first, and then run the batch file.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 9
(4,569 Views)
Could you show me an example of that?


-Matt
0 Kudos
Message 5 of 9
(4,558 Views)
A batch file is called the same way as an exe. To create a simple batch file, just type into a text file the commands you would run from the command prompt. Be sure to give the file the file extension "bat".

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 9
(4,554 Views)
So you're saying at the end of the first batch file I could just change directories to the next batch file?


-Matt
0 Kudos
Message 7 of 9
(4,541 Views)
No, set the directory at the beginning.

Set the directory for the 1st exe, run the executable.
In the second file set the directory for the 2nd exe, run the exe. And so on.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 9
(4,516 Views)

@matt198717 wrote:

Hi all,

 

Attached is the sub vi that i am running in my main application.  I run it twice and change the directory of the file to run.  It appears that after i run this vi that i cant change the directory and it tries to run a file from the incorrect directory.  Does anyone have any advice on how to fix this issue?


I am not sure, if I understand exactly the problem, but do you really need the cmd /c start some_executable.exe. This executes a command prompt window, which executes another command prompt window, where your executable runs.

You can just use cmd /c some_executable.exe some_parameters_if_needed, and you don't need any quotation marks, even if the executable has command line parameters. I you want that the executable runs in particular directory, wire this path to the 'working directory' of System Exec.vi

0 Kudos
Message 9 of 9
(4,498 Views)