Hey all,
Is it possible to lock a folder in the way you can lock a file to prevent deletion/moving by another user?
file := FileOpen(FileName, "r-d")
is this possible with the LockFile function or any other way? Edit: CreateFile?
help appreciated
thanks
Solved by Flipeador below
[Solved] Lock a folder? Topic is solved
[Solved] Lock a folder?
Last edited by gwarble on 28 Aug 2017, 09:32, edited 1 time in total.
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
Re: Lock a folder?
Probably a workaround: http://www.makeuseof.com/tag/how-to-loc ... -computer/
Run/FileSetAttrib/RegWrite/...
Run/FileSetAttrib/RegWrite/...
Re: Lock a folder?
Code: Select all
DirName := A_Desktop . "\1"
R := DllCall("Kernel32.dll\CreateFileW", "Ptr", &DirName, "UInt", 2, "UInt", 0, "Ptr", 0, "UInt", 3, "UInt", 0x2000000, "Ptr", 0, "Ptr")
MsgBox % R
Re: Lock a folder?
Hi Flipeador, would you mind to provide an "unlock"-option as well?! Thx for Ur effortFlipeador wrote:Code: Select all
DirName := A_Desktop . "\1" R := DllCall("Kernel32.dll\CreateFileW", "Ptr", &DirName, "UInt", 2, "UInt", 0, "Ptr", 0, "UInt", 3, "UInt", 0x2000000, "Ptr", 0, "Ptr") MsgBox % R
Re: Lock a folder?
BoBo wrote:Hi Flipeador, would you mind to provide an "unlock"-option as well?! Thx for Ur effort
Code: Select all
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211(v=vs.85).aspx
DllCall("Kernel32.dll\CloseHandle", "Ptr", R)
Re: Lock a folder?
Flipeador, still to test, but thanks!
Edit: Works great, thanks again! My intended use is to lock certain folders with a script running on a server, to prevent those root folders from being accidentally drag'n'drop'ed around by users who have open permissions for creating/deleting
Edit: Works great, thanks again! My intended use is to lock certain folders with a script running on a server, to prevent those root folders from being accidentally drag'n'drop'ed around by users who have open permissions for creating/deleting
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
Re: [Solved] Lock a folder? Topic is solved
so to expand on this, I would actually like to be able to lock from deletion/moving but still be accessible/stuff created/modified/deleted within... in short, the third parameter, dwShareMode = 3
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Code: Select all
DirName := A_ScriptDir "\Test"
FileCreateDir, % DirName
R := DllCall("Kernel32.dll\CreateFileW", "Ptr", &DirName, "UInt", 2, "UInt", 3, "Ptr", 0, "UInt", 3, "UInt", 0x2000000, "Ptr", 0, "Ptr")
MsgBox, Locked!
DllCall("Kernel32.dll\CloseHandle", "Ptr", R)
MsgBox, Unlocked!
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
Who is online
Users browsing this forum: mikeyww and 352 guests