01-15-2014 10:56 AM
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?
Solved! Go to Solution.
01-15-2014 11:25 AM
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..
01-15-2014 11:26 AM
I believe you're looking for the Get Permissions function in the Advanced File I/O palette:
LabVIEW Help: Get Permissions Function
01-15-2014 02:40 PM
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?
01-15-2014 03:19 PM
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.
01-15-2014 03:36 PM
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.
01-16-2014 08:25 AM
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.
01-16-2014 08:27 AM
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?
01-16-2014 08:35 AM - edited 01-16-2014 08:37 AM
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:
01-16-2014 08:39 AM - edited 01-16-2014 08:40 AM
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).