05-04-2010 08:27 AM
HI,
I would like to protect a .txt or .xls file from being erased by mistake. I have changed the Writing rights (attached file and works fine) but I can't find how to forbid the supressing of the file. Can this be done with Labview with windows XP?
Thanks a lot,
User
05-04-2010 08:58 AM - edited 05-04-2010 09:06 AM
Hi User,
did you see the "Set Permissions" function from the File I/O palette?
Edit: If this doesn't help, then you can change the owner of the file. Here is some Code.
Hope it helps.
Mike
05-04-2010 09:45 AM
Hi Mike,
Thanks for your answer. In my attachment I am using the "Set Permissions" Vi but it can only set the writting permission to False when file is created but not forbid its supression, from what I have understood.
User
05-04-2010 12:14 PM
What do you mean by "supression"?
Your subject line says you want to set the permissions for deleting a file. I don't think you can do this. If I look at the properties of the file from within Windows, the only options are to set the file as read only or not.
Is this a file located on a network drive? (Your example shows a c:\ drive.) A network drive has a much larger list of activities that can be allowed or denied. However, that Set Permissions function doesn't look like it has the means to set any of those permissions.
Perhaps there is a way using a Windows .dll call to do this.
05-04-2010 04:35 PM
Hi,
What I would like to do is to avoir deleting (suppressing?) the file by mistake. FOr the moment the VI I posted does only protect the file from being modified....
The file is in a folder on the C: disk
User
05-04-2010 09:55 PM - edited 05-04-2010 09:58 PM
So you want to avoid deleting a file. (I'm going to assume that whatever you meant by "suppressing" was a bad translation to English.)
Looking deeper into this, I see that the more advanced file permissions are a part of the security tab in explorer (as opposed to the general tab). That got me thinking of a command I had never really needed to use before. Look up using "cacls" in a command prompt window. When I did a cacls /? to look up help on my Vista machine, it said it was deprecated and said to use "icacls".
So look for help on either of those and you could feed them into a System Exec.vi function under Connectivity / Libraries and Executables palette.
There may be other ways to change the access control list (cacls) then the command prompt way. If there is, hopefully someone can point them out.
05-04-2010 10:26 PM - edited 05-04-2010 10:36 PM
I wrote the two attached vis to help me set and get permissions in Windows XP.
The only problem is that the set permissions function from the palette stopped working in LabVIEW 2009.
Have a look at what I suggested in this thread as a work around. I wrote it to remove the read only attribute. You will need to invert the logic to set the file's read only attribute.
http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=495139#M495139
05-04-2010 10:47 PM - edited 05-04-2010 10:50 PM
Oops, sorry, I think I attached the wrong version of my Set permissions vi.
The one I attached was after I started fiddling around with it trying to get it working again in LabVIEW 2009.
Here are the original vis (that worked in 8.6.1) if you're interested (8.6.1versions)
05-04-2010 10:53 PM