How to purposefully exclusively lock a file?
Problem
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.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: How to purposefully exclusively lock a file?
Simpler solution: In the directory of interest run from cmd line: As re-directed stdout, it will remain locked until the application (notepad) is terminated. Note that the "filetolock" will be overwritten by the re-direct, so you probably don't want to use an existing file of any importance. An empty "filetolock" won't matter to the application you're trying to test, as the app won't be able to open it anyway.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix