LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot launch external exe

Hi,

 

I have to launch and external exe.

The exe "ComputeRay" is working when I launch it from the command window as shown below.

 

But when I try to launch it with system ("ComputeRay") I get the error file not found (-3).

 

How could I make it work?

CMD window.jpg

 

0 Kudos
Message 1 of 8
(4,759 Views)

Have you tried passing the complete pathname of the executable including the extension?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 8
(4,752 Views)

Yes I tried the complete path with extension.

In fact before launching “ComputeRay” I’m running a .bat file which is setting some Environment variables and adds some directories to the variable Path.

I made some tests with the cmd window from Windows. Each time I’m closing the cmd window and reopen it I have first to run the .bat files before running ComputeRay.

I’m also running these .bat files with the system() function from the CVI program but it looks like the new Environment variables are not kept active after the system() function finishes execution in the same way as what is happening with the cmd window.

So my question now is: How can I keep active Environment variables between 2 successive system() function calls?

0 Kudos
Message 3 of 8
(4,747 Views)

I may be wrong, but it's my opinion that using two consecutive calls to system () is equivalent to open a command prompt, call the exe, closing the window, opening a new command prompt and calling the other program.

 

The easiest solution could be to add the last call inside the batch file make one call only to system. Alternatively you could try editing environment variables like PATH with _putenv () function. You could also try to edit _default.pif file (or whichever is its equivalent in Win7/8 OSs) as described in the help for system ().The last resource could be to permanently set environment variables in your system as described in this guide



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 8
(4,741 Views)

Just for precision, the solution I have adopted in a situation similar to yours was to edit the batch file adding the program to run.

All other suggestions are ideas that came to my mind but I have not tested them.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 5 of 8
(4,731 Views)

Thank you Roberto for your inputs.

 

In the mean time I have made some tests and I found that in the system() function you can use & to launch successively several programs. So if I write system (MyBatch.bat & MyExe.exe) it is also working.

0 Kudos
Message 6 of 8
(4,720 Views)

That's good news for you... and gret surprise for me! Smiley Surprised I didn't realized it was possible: I would have never thought to it!

Can you add some more details on that? Is this feature documented somewhere?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 8
(4,716 Views)

I don't know if this feature is documented in the CVI documentation.

 

During my tests to solve my issue I saw that in the parameters one can possibly put behind cmd.exe there was the "&". So I made the test with the system() function and it worked.

0 Kudos
Message 8 of 8
(4,709 Views)