LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing ProgramFile with VI

Hello all,

 

I wrote a Vi which is creating a file in the program folder where the vi is running in. During testing in Labview everything is working fine.

 

Now I created an installer to put the final vi as an exe to the c:\ProgramFile directory. When I open the program now the error massage appears that I do not have access to this folder ( I guess due to Windows limitations ).

Is there anything I can do to get access with my vi? Do I need to make a setting I haven't found or do I need to save everything somewhere else?

 

Many thanks in advance

 

0 Kudos
Message 1 of 6
(2,738 Views)

Hi Danger,

 

I wrote a Vi which is creating a file in the program folder where the vi is running in.

That is the core of the problem. Don't create files in the program folder!

 

Microsoft recommends the user accessable folders like UserAppData and CommonAppData! Use them to have file access with each user account!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,733 Views)

What GerdW has said is correct - you shouldn't really be writing to files inside Program Files in Windows > XP as it's no longer recommended practice by Microsoft.

 

What you can do, however, is tick the 'unlock' box on the folder your application is installed to in the installer build specification. This will make the folder user writeable so your application can write to files in it.

 

If you decide to use CommonAppData, you may need to 'unlock' a directory in there anyway (and I also had to put a file in it otherwise it didn't get unlocked properly).


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 3 of 6
(2,721 Views)

@Dangermou5 wrote:

I wrote a Vi which is creating a file in the program folder where the vi is running in. During testing in Labview everything is working fine.


You don't say how you are obtaining the path, but you should also be aware that e.g. "current VIs path" will need an adjustment when used from inside an executable. See this article for example.

0 Kudos
Message 4 of 6
(2,698 Views)

I totally agree with the others...but if you really want to stay with the old mind set of doing things in the Program Files folder you can.  When making an NI installer you can choose to "Unlock" files, which basically means allow them to be read/write for all users, not just administrators which are the ones that normally have full rights to the Program Files folder.

 

http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/build_installer/

Message 5 of 6
(2,689 Views)

I often make executables, and LabVIEW's Application Builder usually puts them in <Project Folder>\builds\... -- this directory is typically somewhere in <My Documents>, perhaps in <LabVIEW Default Data Directory>.  If I build this on a shared PC so that others can run it, I forget that "John" and "Mary" do not have access to my Documents folder when they log in to Windows.  So I try to remember to specify a Destination Directory for the Build in <Users>\Public\Public Documents, and to put any Shortcuts that I create to the Executable on <Users>\Public\Public Desktop.  This solves the "Accessibility" problem for us.

 

Bob Schor

0 Kudos
Message 6 of 6
(2,669 Views)