09-20-2023 08:54 AM
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?
09-20-2023 09:22 AM
@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.
09-20-2023 09:22 AM
Hi,
Use the "Current VI's Path" primitive from palette "File I/O" -> "File Constants":
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.
09-20-2023 09:23 AM
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.
09-25-2023 04:04 AM
Note that you don't need "This VI" if you're want a property for the current VI:
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.