LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resolve shortcut in VI Path

I need to open an INI file using 'Open Config Data' based on a path. The full path contains a shortcut element.

 

'Open Config Data' returns error 7, but the file exists; IF you browse using Windows Explorer. LabVIEW functions don't seem to be able to resolve the shortcut when it is within the path (not the end of the path).

 

Why is this a problem? I'm actually trying to follow a NI TestStand shortcut in order to access the StationGlobals.ini file in the Cfg\ subdirectory.

 

Is there a function or way to have LabVIEW resolve the shortcut path? I've taken a stab at a VI to do this, but it seems a bit of a kludge.

 

See attached ( LabVIEW 8.6)

0 Kudos
Message 1 of 5
(3,929 Views)

My attached VI had a problem; see this VI. If you have TestStand 4.1 installed, it should resolve to the actual path of the StationGlobals.ini file (depends on your OS)

Message Edited by Phillip Brooks on 10-21-2008 11:23 AM
0 Kudos
Message 2 of 5
(3,904 Views)

I ran your code and the only time I got error 7 was when the default path did not exist. If you do not wire in an input to the Resolve Shortcut Path 2.vi path input the path is the saved default. If that does not exist than the Open Config Data.vi will throw an error. The only time that I got the # Shortcuts Resolved to output 1 and not 0 was when I actually deleted the.lnk from the path.

 

What exactly are you trying to do? Are you just trying to see that a shortcut exists? If so why are you adding the .lnk extention?

Vince M
Applications Engineer
0 Kudos
Message 3 of 5
(3,871 Views)

I have a collection of code developed in LV 7.0 TS 3.0 that modifies StationGlobals.ini. I am upgrading it to LV 8.6 / TS 4.1.

 

My code determines the path to the station globals by using a variable read from an application specific ini that contains the path to the sequence editor (default = C:\Program Files\National Instruments\TestStand 4.1\Bin\SeqEdit.exe).

 

This code reads the string, converts it to a path, strips the path (two times) to determine the base path of TestStand ( C:\Program Files\National Instruments\TestStand 4.1 ) and finally appends Cfg\StationGlobals.ini.  This file is opened using the Open Config Data functions and updates are applied. This code returns error 7 when I run it under LV 8.6 / TS 4.1

 

I am assuming LabVIEW can't traverse the folder shortcut to find the new location of StationGlobals.ini. (See TestStand Directory Relocation)

 

Note that this shorcut is part of TestStand and provided by NI, I did not create it. I assume that the shortcut was created to ease the finding of the Cfg files, but it appears that LabVIEW can't resolve a path that contains a folder shortcut.

 

If I use my new Resolve Shortcut Path 2.vi and  pass in the path C:\Program Files\National Instruments\TestStand 4.1\Cfg\StationGlobals.ini, it will check each component of the path and resolve the folder shortcuts.

 

Note that the actual location of the Cfg folder is OS dependent. If you use XP, its under Documents and Settings\All Users\Documents, and if you use Vista its under User\Public\Documents.

 

I want to minimize the changes to my existing code. I would like to use the shortcut that NI provided with TestStand.If I use XP right now, but if I install on a new computer using Vista later, I would like the code to just keep working by following the path that the TestStand installer creates.

 

I added the .lnk to the end of each element of the array because the File/Directory Info VI will return shortcut = false if you pass in Cfg, but works properly if you pass in Cfg.lnk. ( I think because the shortcut is a file with a pointer to the noew location). I found this .lnk trick somewhere on the NI or LAVA forums...

 

In the end I can use my Resolve Shortcut Path 2.vi to find the REAL path to the file, but thought there may be a LV native way of doing what I am doing. I didn't post this as a TestStand question because this problem seems to exist if I create an arbitrary shortcut to a folder.

 

Here is an example VI to run with Resolve Shortcut Path 2.vi

 

 

Message Edited by Phillip Brooks on 10-22-2008 04:36 PM
0 Kudos
Message 4 of 5
(3,861 Views)

I created a test.ini file at location C:\Program Files\Test\test.ini. I right clicked on that file and created a shortcut. I moved that shortcut to my desktop. When I right-click the shortcut and look at the properties it says that it's name is: Shortcut to test.ini; Location: C:\Documents and Settings\vmethot\Desktop; Target: C:\Program Files\Test\test.ini. But when I browse for the shortcut on my desktop using your Resolve Shortcut Path 2.vi and select the shortcut the name that shows up in the File Name box is: Shortcut to test.ini.lnk

 

If I choose to open the shortcut it puts the Target in the path. When I run it the Resolved Path Exists? outputs a true and the # Shortcuts resolved is 0. If I paste in to the path C:\Documents and Settings\vmethot\Desktop\Shortcut to test.ini then Resolved Path Exists? ouputs true and # Shortcuts resolved is 1. If I paste in to the path C:\Documents and Settings\vmethot\Desktop\Shortcut to test.ini.lnk then Resolved Path Exists? ouputs true and # Shortcuts resolved is 0.

 

Whenever I put something in the path where a folder of the path does not exist then Open Config Data.vi throws error 7. If I put a non-existing file but the folder path exists and I leave the Create file if necessary (T) unwired then Does file exist?.vi throws the error internal to the Open Config Data.vi but it creates the file and clears the error.

 

I do not have TestStand but your Resolve Shortcut Path 2.vi is telling the truth when it says that a file or file path does not exist. Which means that this is a TestStand question.

Vince M
Applications Engineer
0 Kudos
Message 5 of 5
(3,837 Views)