LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about the "This VI" Reference

I need to get the path of the VI while running it as an executable, can i get it from the "This VI" reference or does it always refer to the VI itself, even when im launching the .exe file?

0 Kudos
Message 1 of 5
(929 Views)

@domcorrado wrote:

I need to get the path of the VI while running it as an executable, can i get it from the "This VI" reference or does it always refer to the VI itself, even when im launching the .exe file?


It is a reference to the VI.  Use Current VI's Path (File I/o->File Constants palette) to get the path of the VI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(914 Views)

Hi,

 

Use the "Current VI's Path" primitive from palette "File I/O" -> "File Constants":

raphschru_0-1695219655772.png

It works even if the VI is compiled inside an executable.

However be aware that the name of the executable is added to the path of the compiled VI.

 

Example:

Normal VI path: C:\MyProject\source\Main.vi

VI path inside executable: C:\MyProject\builds\MyExe.exe\Main.vi

 

Regards,

Raphaël.

0 Kudos
Message 3 of 5
(913 Views)

Instead of waiting for an answer you could have just created a simple executable that displays the returned path. 😄

 

It still returns the path of the VI, but you can use strip path to get the path of the executable. Start reading here.

0 Kudos
Message 4 of 5
(910 Views)

Note that you don't need "This VI" if you're want a property for the current VI:

wiebeCARYA_0-1695632500675.png

 

If you leave the VI reference unwired, it defaults to the current VI.

 

If you want to pass the reference to other VIs you do need "This VI".

 

Paths to VIs in executables have a bit of a code smell... There might be better ways to do what you want.

Message 5 of 5
(789 Views)