I want to hold an exclusive lock on a file so it cannot be read or written by anything else. Is there a simple Windows tool or command to do this?

I suppose the tool or utility would implement the LockFileEx Windows Function.

Note: I've tried text editors like Notepad and Notepad++ on a text file but they don't hold an exclusive lock on it.

link|improve this question

64% accept rate
Why not just make one? Also, how long should they hold the lock? Should they wait for some event? – Mehrdad Jun 9 '11 at 2:38
I considered programming one but figured there's a quick tool, editor or command I can use. On superuser not all users are programmers. bit.ly/lXT6ey I didn't want to go the Stackoverflow route with this question. Am testing the behaviour of an app when it can't access files. – John K Jun 9 '11 at 2:53
I might be able to make one for you -- just lemme know when the lock should be released. – Mehrdad Jun 9 '11 at 2:57
feedback

2 Answers

Open it with MS-Excel... this app locks a file while open.

link|improve this answer
feedback

Try Easy File Locker (freeware).

enter image description here

link|improve this answer
Works great for me. +1 Thanks. – John K Jan 25 at 5:05
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.