LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to open files using the Windows associated program?

I have a LV program that is generating a list of files that I may want to open using the associated Windows program. Some are standard Office files but others require proprietary analysis programs.  All have Windows associations such that I can double click on the file name in the Windows file manager and launch the appropriate program. I would like to mimic this behavior within my LV program but without coding a case for each file extension, some of which I may not anticipate now.

0 Kudos
Message 1 of 9
(4,649 Views)
Try using the system exec function and just send it the file name (perhaps need path to it as well).  It should behave the same as if you opened a command prompt and just typed the filename.
Message 2 of 9
(4,644 Views)

Have a look at vi.lib\platform\browser.llb\open a document on disk.vi.

 

It tries to use DDE, and if that fails, tries to build a command line as Ravens Fan suggested.


___________________
Try to take over the world!
Message 3 of 9
(4,629 Views)
 
0 Kudos
Message 4 of 9
(4,609 Views)

tst wrote:

Have a look at vi.lib\platform\browser.llb\open a document on disk.vi.

 

It tries to use DDE, and if that fails, tries to build a command line as Ravens Fan suggested.


 

Thank you Yair!

 

I did NOT know that.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 9
(4,602 Views)
Very Nice!
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
0 Kudos
Message 6 of 9
(4,582 Views)
I should point out that this obviously only works in Windows (unless NI has an alternate implementation for the other OSes) and that DDE is an old technology and might go out the window in a future version of Windows. Also, I seem to remember having some problems in the past when using that VI. I think that it was not building the path correctly, but I don't remember the details. It might have been an issue with spaces in the path, but I don't think it was as simple as that.

___________________
Try to take over the world!
Message 7 of 9
(4,566 Views)

There are some problems with that VI.  I have one user that I had to track a problem down with trying to open a PDF file.  Their registry key HKEY_CLASSES_ROOT\.pdf was read in with a value of "AcroExch.Document                 " (with a lot of spaces after it), which prevented this VI from finding the next key (AcroExch.Document\shell\open\command) which identifies the path to Adobe Acrobat.  Instead of getting the path to Adobe Acrobat, I got back "Adobe Acrobat 7.0 Document" as the path (see attached error).

 

I checked the key with the Windows registry editor, and it did NOT show the extra spaces.  However, just opening the key and selecting OK (without making changes) was enough to clear the problem.

 

Not sure if this problem is with the registry keys that Adobe Acrobat created when it was installed or upgraded (the user was on version 9.0, but there are older versions on that machine, too), or if the problem was with the LabVIEW registry key readers in Open a Document on Disk.vi.

Message Edited by Joe Gerhardstein on 05-13-2009 03:13 PM
Message Edited by Joe Gerhardstein on 05-13-2009 03:17 PM
Joe Gerhardstein
Viasat
Certified LabVIEW Architect
Certified TestStand Developer
Certified Professional Instructor
http://www.viasat.com
0 Kudos
Message 8 of 9
(4,201 Views)

The VI mentioned by Yair works on the Macintosh by calling an Applescript which tells the Finder to open the file.  The code segment shown in the image also works via the System Exec.vi.  The quotes " " are to allow the Unix shell called by the VI to handle filenames with spaces.

 

Lynn 

Message Edited by johnsold on 05-14-2009 10:24 AM
0 Kudos
Message 9 of 9
(4,172 Views)