LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Launch a File Programmatically in its Default Application" is inconsistent

I'm trying to use the example in "Launch a File Programmatically in its Default Application"
http://decibel.ni.com/content/docs/DOC-6125

 

This code works, but I find that Windows sometimes decides that it cannot find the file that I want to launch. Very frustrating... I'm trying to figure out why, and it's certainly not because I'm providing the incorrect file path.  I'l have it working, and then suddenly, it will stop working, giving a popup indicating that Windows can't find the file. I've tried lots of different things to get my arms around what's happening, thinking that it has something to do with security, but I can't crack this nut.  Any thoughts?

 

Thanks, Alan

0 Kudos
Message 1 of 7
(3,108 Views)
If it's the error I think you're talking about , then it's because Windows has a built-in timeout on opening files. If it detects that the file hasn't opened within a certain amount to time it will give you the error. It's not a true error, as the file should open eventually. You typically see this problem if Windows is busy doing something else, or you have some process that's eating up all the CPU. It's also possible if you're trying to open a file from a network.
0 Kudos
Message 2 of 7
(3,095 Views)

Hi smercurio,

 

The error window pops up immediately, with the text "Windows cannot find 'myfile.pdf'. Make sure you tyed the name correctly, and then try again."

 

The file is not on a network drive - it's local.  I wonder if part of the issue is that I want to do this from within an executable.

0 Kudos
Message 3 of 7
(3,090 Views)

Hi ajb,

 

"I wonder if part of the issue is that I want to do this from within an executable."

Well, maybe. How do you get the path to the PDF?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(3,080 Views)
It would be easier to see what's going on if you post your VI, or at the very least a screenshot (NO bitmaps). For instance, what's the exact command string that you're feeding to System Exec?
0 Kudos
Message 5 of 7
(3,065 Views)

Hello smercurio, GerdW,

 

 I'm able to demonstrate my problem without anything other than the attached VI. No executable required...  (phew!)  BTW, I'm using LV 2009 within Windows Vista. I can try this using XP tomorrow...

 

Here's what I do to exhibit the problem:

 

1) Start up LabVIEW, and open the attached VI.

2) Run the VI, which for me should open the file "C:\Users\SRSC\Documents\launch issue.txt"

3) Instead of the file launching, I get the attached popup error, and the "standard error" output from System Exec returns "The system cannot find the file launch issue.txt."  This is repeatable if I run the VI again...  The command being issued, according to the VI's indicator is cmd /x /c start "C:\Users\SRSC\Documents" "launch issue.txt"

 

Now it gets strange.

 

4) Click the Browse button next to the  path control to get the Open File dialog

5) Select another file

6) Click the Browse button again, and select "launch issue.txt", which is essentially going back to the default path. You can also "Reinitialize Values To Default"

7) Run the VI... I find that the file "launch issue.txt" now successfully launches!  The command issued is the same as in step 3... cmd /x /c start "C:\Users\SRSC\Documents" "launch issue.txt" 

 

I have to conclude that step 3 really isn't issuing the command string to System Exec... 

 

If I close LabVIEW without saving the VI, the above steps are completely reproducible.

 

Cheers, Alan

 

Download All
0 Kudos
Message 6 of 7
(3,043 Views)

Hi Alan,

 

The example doesn't work for me as well (LV 8.5, but this shouldn't matter).

If I change it to the format

cmd /x /c start "" "C:\Users\SRSC\Documents\launch issue.txt"

it works just fine.

 

Try the attached VI.

 

Hope this helps,

Daniel

 

 

0 Kudos
Message 7 of 7
(3,033 Views)