Locking Files
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 344
- Joined: Tue Feb 24, 2009 6:14 pm
- Location: Philippines
- Contact:
Locking Files
Can anybody help me with locking up local files in a Windows platform? I tried "open file myFile" without close file command but it would only prevent me from actually deleting the opened file.. What I need for it to do is that when the user opens (E.g., a text file through notepad) it would display an "Access denied." error thus preventing the user from seeing the contents of the file. Thanks a lot for the replies in the future....
Re: Locking Files
shadowslash,
You could use VBScript to toggle the writable attibute. You can also toggle the visible and system attributes.
Best,
Mark
You could use VBScript to toggle the writable attibute. You can also toggle the visible and system attributes.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Re: Locking Files
shadowslash
You can hide any file or folder by changing its attribute. For example, I've a text file "Test.txt" in my desktop. I've changed its attribute by the following script -
Now the text file become hidden system file. You can't see this file even you check "Show hidden files and folders" from Folder Options.
To get it back, just change the last line to -
Note: If you uncheck "Hide protected operating system files (Recommended)" from Folder Options, then the file or folder can be seen even it is in hidden mode.
You can hide any file or folder by changing its attribute. For example, I've a text file "Test.txt" in my desktop. I've changed its attribute by the following script -
Code: Select all
on mouseUp
put specialfolderpath(0) & "/Test.txt" into myFile
replace "/" with "\" in myFile
set the hideconsolewindows to true
get shell("attrib" && quote & myFile & quote && "+s +h")
end mouseUp
To get it back, just change the last line to -
Code: Select all
get shell("attrib" && quote & myFile & quote && "-s -h")
-
- Posts: 344
- Joined: Tue Feb 24, 2009 6:14 pm
- Location: Philippines
- Contact:
Re: Locking Files
@alemantareq, I know about that command line switch. It's just not the one I've been looking for, anyway, I've found the solution and is now happy with it. I've made Lock It!.
You can get the Windows-only version at: http://www.mediafire.com/file/zmbjncmmy ... t_1-00.exe
You can get the Windows-only version at: http://www.mediafire.com/file/zmbjncmmy ... t_1-00.exe
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Re: Locking Files
shadowslash
You really done an excellent job! Once upon a time, it was also in my mind. Can you share a little how you've made it?
You really done an excellent job! Once upon a time, it was also in my mind. Can you share a little how you've made it?
-
- Posts: 344
- Joined: Tue Feb 24, 2009 6:14 pm
- Location: Philippines
- Contact:
Re: Locking Files
Here's a snippet from the code I used in the Lock button.alemrantareq wrote:shadowslash
You really done an excellent job! Once upon a time, it was also in my mind. Can you share a little how you've made it?
Code: Select all
put empty into tError
set the itemDel to backslash
cmd ("cacls" && quote & tLine & quote && "/d Everyone /e")
if the result is "The Cacls command can be run only on disk drives that use the NTFS file system." then
put "The drive <b>" & item 1 of tLine & "\" & "</b> is invalid. Please transfer the file or folder to another drive." into tError
else if line 1 of the result is ("The system cannot find the file specified.") then
put "The file or folder defined does not exist or has already been moved to a different location." into tError
else if line 1 of the result is ("The device is not ready.") then
put "The drive <b>" & item 1 of tLine & "\" & "</b> is not yet mounted or is not existent." into tError
else if line 1 of the result is not ("processed file: " & tLine) and \
line 1 of the result is not ("processed dir: " & tLine) then
put the result
put "An unknown error occured while processing file or folder." into tError
end if
if tError is not empty then
answer warning tError with "Continue" titled tLine
end if