LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting permissions on files and folders created with MakeDir

Hi,
My program uses MakeDir() to create a directory where calibration data etc. is stored.
By default the owner of the folder and files within it is the user who happens to be logged on when it is created and the permissions are set as "Read & Execute" for other users.
I want all users, not just the owner and administrators to be able to update the files.
Is there a way to set the permissions programatically? SetFileAttrs() only works for users who already have permissions "Full Control", "Modify" and/or "Write"
0 Kudos
Message 1 of 6
(4,902 Views)
 

Hi,

  I'm currently investigating into this.

Please bear with me whilst I work out how to convert the c# source code I have into CVI. I've made a piece of code which runs, but isn't changeing the permissions, whereas the c# code does work fine.

If you want to have a look at the work in progress, you can download it from here :

ftp://ftp.ni.com/outgoing/     for the zip file : 332174 directory permissions.zip

since it's too large to attach here, since the .fp files that wrap the Active DS Type Library
and the
ADsSecurity 2.5 Type Library (the .msi installer for this is available from the previous link, or in the .zip file)
are about 2.5MB each.
 
It's a conversion of the c# code here :
 
 
Thanks
Sacha Emery
National Instruments (UK)
// it takes almost no time to rate an answer Smiley Wink
Message 2 of 6
(4,859 Views)
Great, thanks very much, I'll look forward to the finished item.
I just downloaded and tried the interim version, but it crashed.
0 Kudos
Message 3 of 6
(4,858 Views)
Another thing you could try is to use the command line utility cacls.exe to modify the access control list for that folder to give all users Full access (or what ever specific permissions you want to give).

It would look like the following:

MakeDir("c:\\testdir");
system ("cacls c:\\testdir /c /e /g BUILTIN\\Users:F");

I hope this helps





Bilal Durrani
NI
Message 4 of 6
(4,827 Views)
Hello Sacha,
 
I know this is a very old post (2 years+), but i was wondering if you ever successfully converted that C# code for setting file permissions to CVI...?
 
JB
--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 5 of 6
(4,312 Views)
Hi,

I ended up using the command line utility as suggested and added the functionality to the distribution kit, so that after the program is installed the folder is created and the permissions set. This is quite useful as it can also install a default set of calibration files at the same time.

Ros
0 Kudos
Message 6 of 6
(4,220 Views)