LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

windows permissons

Solved!
Go to solution

Hi I have an issue with my LV App being able to write to a directory that may be set as read only.  IS there any way to check and if so, change the permission of this directory from Labview?

 

 

0 Kudos
Message 1 of 14
(4,271 Views)

Please go thorough the link : http://zone.ni.com/reference/en-XX/help/371361H-01/glang/setting_permissions/

 

I think this might slove you problem..

 

Thanks

Message 2 of 14
(4,251 Views)
Solution
Accepted by topic author id

Hello id,

 

I believe you're looking for the Get Permissions function in the Advanced File I/O palette:

 

LabVIEW Help: Get Permissions Function

http://zone.ni.com/reference/en-XX/help/371361K-01/glang/access_rights/

 

Regards,

Tom L.
0 Kudos
Message 3 of 14
(4,249 Views)

Thanks, but the set permissions VI doesnt seem to work.  See attached.  After executing this code, this is what the windows dir permissions look like - they are unchanged.  Is there something else that I must do before this or something?

 

0 Kudos
Message 4 of 14
(4,208 Views)

I'm not sure if Set Permissions works recursively on every folder inside of ProgramData.  Even if it does, setting all of Program Data to be writeable by anyone is a bad idea.  At most you should be setting only the folders inside of ProgramData that you own as writeable, eg. C:\ProgramData\MyApp.

 

Since ProgramData is a system folder you may not have the permissions required to set it and everything inside to be writeable.  Try with a subfolder and see if you don't have better luck.

0 Kudos
Message 5 of 14
(4,196 Views)

Hello id,

 

I ran a few quick tests and the function looks to be working as expected, but remember a few things:

 

1) The set permissions function isn't recursive.  If you want to alter the permissions of all files contained in a folder you'll need to do it one at a time.  I'd be surprised if there isn't an example around that already does this, but if you need to create it yourself it should be as easy as using the recursive file list function, also available in the advanced File Functions palette.

 

2) The LabVIEW development environment or a LabVIEW-built executable may not have permission to modify the settings of certain files or folders depending on their security settings. Top-level OS directories and their contents are likely protected.

 

In the screenshot you provided (thanks for that, by the way!) it looks like the folder is flagged as having some read-only contents.  This is what I'd expect after setting the folder's permissions.

Tom L.
0 Kudos
Message 6 of 14
(4,184 Views)

Thanks I already did and it did the same - no change to the read only.   I have program xml support files in C:\program data under its own folder because thats what the NI help desk told me to do.  When I install the program on a new PC, I need to set permissions on this folder so I can read/write to it during program operation.

0 Kudos
Message 7 of 14
(4,139 Views)

Tom if Labview cant set the permissions of a folder, how can you create an app that has data files that are written to or read? 

0 Kudos
Message 8 of 14
(4,135 Views)

Hi id,

 

when it comes to Windows behaviour you should ask Microsoft and not NI.

 

MS suggests to use UserAppData for your program settings. In this folder the current user always has write permissions! Usually it is located in "users\username\ApplicationData\Local" (or similar, don't have Win7 at hand)...

 

You can find that folder very easily:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 14
(4,128 Views)

I had the same problem - I have a couple of related applications that need to share & read/write to a configuration file in [Public App Data]\MyApp.

 

The solution that I found is that I had to include a file (I used a placeholder file) inside the [Public App Data]\MyApp in my installer and then tick the 'unlock' option on that folder. After the installation is complete, my applications can then read/write files inside the [Public App Data]\MyApp folder.

 

I think the reason for the placeholder file is that without it, the 'Unlock' setting of the folder does not seem to apply correctly.

 

I don't think this is a problem if you use a user-specific location (such as user appdata).


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 10 of 14
(4,124 Views)