A powerful Windows file lock detection and unlock utility.
- 🔍 Lock Detection: Identify which processes are locking files or folders
- 🔓 Force Unlock: Terminate processes that are locking files (with confirmation)
- 📊 Real-time Monitoring: Monitor file locks with configurable intervals
- 🖱️ Context Menu Integration: Right-click integration for easy access
- ⚡ Fast & Lightweight: Built with Rust for optimal performance
- 🛡️ Safe Operations: Confirmation prompts before terminating processes
- Windows 10/11
- Administrator privileges (required for context menu installation)
If you don't want to build the project yourself, you can download the latest pre-built executable:
- Go to the Releases page
- Download the latest
file-lock-checker.exe - Place it anywhere you prefer, or add it to your
PATHfor easy access via terminal
If you prefer to build the project manually:
# Clone the repository
git clone https://github.com/mantvmass/file-lock-checker.git
cd file-lock-checker
# Build the project in release mode
cargo build --release
# Copy the built executable to the project root (optional)
copy target\release\file-lock-checker.exe .-
Run as Administrator:
# Right-click on install_context_menu.bat # Select "Run as administrator" -
Or use command line:
# Open Command Prompt as Administrator install_context_menu.bat -
Or use file-lock-checker.exe option:
# Open Command Prompt as Administrator file-lock-checker.exe install
This adds three options to your right-click context menu:
- FLC Check - Check file locks
- FLC Unlock - Unlock files
- FLC Monitor - Monitor files
# Check which processes are locking a file
file-lock-checker.exe check "C:\path\to\your\file.txt"
# Unlock a file by terminating locking processes
file-lock-checker.exe unlock "C:\path\to\your\file.txt"
# Monitor file locks in real-time (default: 2 second intervals)
file-lock-checker.exe monitor "C:\path\to\your\file.txt"
# Monitor with custom interval (5 seconds)
file-lock-checker.exe monitor "C:\path\to\your\file.txt" 5- Right-click on any file or folder
- Select one of the FLC options:
- FLC Check: Opens terminal showing locking processes
- FLC Unlock: Prompts for confirmation before killing processes
- FLC Monitor: Starts real-time monitoring in terminal
file-lock-checker.exe check "C:\temp\document.docx"Output:
File 'C:\temp\document.docx' is locked by 2 process(es):
--------------------------------------------------------------------------------
Process #1
PID: 1234
Name: WINWORD.EXE
Path: C:\Program Files\Microsoft Office\OFFICE16\WINWORD.EXE
Process #2
PID: 5678
Name: explorer.exe
Path: C:\Windows\explorer.exe
file-lock-checker.exe unlock "C:\temp\document.docx"Output:
File 'C:\temp\document.docx' is locked by 1 process(es):
--------------------------------------------------------------------------------
Process #1
PID: 1234
Name: WINWORD.EXE
Path: C:\Program Files\Microsoft Office\OFFICE16\WINWORD.EXE
Do you want to kill these processes? (y/N): y
Successfully killed process: WINWORD.EXE (PID: 1234)
Rechecking file locks...
File 'C:\temp\document.docx' is now unlocked
file-lock-checker.exe monitor "C:\temp\document.docx" 3Output:
Monitoring file locks for: C:\temp\document.docx
Update interval: 3 seconds
Press Ctrl+C to stop monitoring
[2024-08-07 14:30:15] Lock status changed:
File is LOCKED by 1 process(es):
PID: 1234 | Name: WINWORD.EXE | Path: C:\Program Files\Microsoft Office\OFFICE16\WINWORD.EXE
[2024-08-07 14:30:45] Lock status changed:
File is now UNLOCKED
File Lock Checker uses the Windows Restart Manager API to identify processes that have handles to specific files. This is the same underlying technology used by Windows Update and other system tools to determine which applications need to be restarted.
Key APIs used:
RmStartSession- Initialize Restart Manager sessionRmRegisterResources- Register files to checkRmGetList- Get list of processes using the resourcesTerminateProcess- Force-kill locking processes
- Kernel-level Locks: Some system files locked by kernel drivers may not be detected
- System Services: Critical Windows services may not appear in results
- Administrative Rights: Some operations require elevated privileges
- ✅ Regular files (.txt, .docx, .xlsx, .pdf, etc.)
- ✅ Executable files (.exe, .dll, .msi, etc.)
- ✅ Media files (.mp4, .avi, .mp3, etc.)
- ✅ Database files (.db, .sqlite, .mdb, etc.)
⚠️ System files (.sys, kernel drivers) - limited detection⚠️ Registry files - limited detection
[dependencies]
winapi = { version = "0.3.9", features = [
"handleapi", # CloseHandle, INVALID_HANDLE_VALUE
"processthreadsapi", # OpenProcess, TerminateProcess, GetCurrentProcess
"psapi", # EnumProcesses, GetModuleBaseNameW, GetProcessImageFileNameW
"restartmanager", # RmStartSession, RmEndSession, RmRegisterResources, RmGetList
"winnt", # PROCESS_* constants, HANDLE
"minwindef", # DWORD, FALSE, TRUE
"ntdef", # HANDLE definition
"winreg", # Registry functions
"winnt", # Registry constants
"winerror", # ERROR_MORE_DATA และ error constants อื่นๆ
] }
chrono = "0.4.41"1. "Access Denied" errors
- Run as Administrator
- Some system processes cannot be terminated
2. No processes found but file still locked
- File may be locked by kernel drivers
- Try using
handle.exefrom Sysinternals for deeper analysis
3. Context menu not appearing
- Ensure installation script ran as Administrator
- Try logging out and back in
- Check Windows Registry entries
4. False negatives for .sys files
- System driver files use kernel-level locks
- Restart Manager API has limitations with kernel resources
If context menu installation fails, manually remove these registry keys:
reg delete "HKCR\*\shell\FLC_Check" /f
reg delete "HKCR\*\shell\FLC_Unlock" /f
reg delete "HKCR\*\shell\FLC_Monitor" /f
reg delete "HKCR\Directory\shell\FLC_Check" /f
reg delete "HKCR\Directory\shell\FLC_Monitor" /f# Run as Administrator
uninstall_context_menu.bat
# or use file-lock-checker.exe option
file-lock-checker.exe uninstallSimply delete the executable and associated files:
del file-lock-checker.exe
del install_context_menu.bat
del uninstall_context_menu.bat# Prerequisites
rustup install stable
rustup default stable
# Clone and build
git clone https://github.com/mantvmass/file-lock-checker.git
cd file-lock-checker
cargo build --release# Test with a file you know is locked
python lock_test.py "C:\path\to\your\test.txt"
# In another terminal:
cargo run -- check "C:\path\to\your\test.txt"The codebase is structured for easy extension:
src/main.rs- Core logic and CLI interface- Context menu integration via Windows Registry
- Real-time monitoring with configurable intervals
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.