From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LaunchExecutableEx() does not return -4 when path to exe is not found

Solved!
Go to solution

LaunchExecutableEx() is not returning an error (-4 or -3) event though path to the file does not exist on the PC I'm runing the application on. It returns 0 (as if the exe was sucessfull).

 

Thanks,

Mira

0 Kudos
Message 1 of 9
(5,295 Views)

It would be useful to add some more details, version of OS and CVI...;

 

For me, when running LaunchExecutableEx () (CVI2013SP2 and Win7 64 bit) with a non-existing file ("C:\test.exe") I receive error -19 (The operating system returned an unknown error code).

0 Kudos
Message 2 of 9
(5,283 Views)

I am currently using WIndows XP and Lab Windows 10.0.1

 

The LaunchExectuableEx returned no error even though the path or file were not existing.

0 Kudos
Message 3 of 9
(5,124 Views)

Can you post a snippet of your code and explain what the intent of the code is?

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 4 of 9
(5,100 Views)

Hi Steve,

status = LaunchExecutableEx ( command, LE_SHOWNORMAL, &ExecHandle.crt );

I launch Java script that will perfrom certain operation and write result to a file. I'd like to be able to distinguish when the executable did not launch vs, when executable failed to perform it's operation (due to some other reasons). When the executable is in the path the LaunchExecutableEx will launch it, but when it's not there the LaunchExecutableEx still returns 0.

0 Kudos
Message 5 of 9
(5,075 Views)

Do you see this behavior only in this code you wrote? Does the same thing happen when you run the launchexe example as well? (In Example Finder: Communicating with External Applications>>Operating Systems>>launchexe.cws)

 

When I run this example and select a non-existant file, I receive error code -3 (File was not found) as expected.

Steven Gloor
Staff Customer Engineer - CTA, CLD
0 Kudos
Message 6 of 9
(5,056 Views)
Solution
Accepted by mdokic

The example works. I thing I understand the problem. 

What I pass to the LaunchExecutable isn't just path to exe. I pass java -jar + path to exe + path to XML. All LaunchExecutableEx knows is that it launched java -jar (hence it returns 0). Path to java executable is irrelevant to LaunchExecutableEx.

I guess I'll have to do something else prior to call to LaunchExecutableEx to verify that java executable and XML are present.

0 Kudos
Message 7 of 9
(4,994 Views)
Solution
Accepted by mdokic

There's a FileExists function in the Programmer's Toolbox

Message 8 of 9
(4,958 Views)

Thanks!

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