wholock is a command-line utility written in Rust that detects which processes are locking files or directories on Windows and optionally terminates them.
It is inspired by File Locksmith from Microsoft PowerToys, adapted for a pure CLI workflow.
- Scan -- List processes that hold a lock on your files
- Kill -- Terminate locking processes with per-process confirmation or interactive selection
- Watch -- Monitor lock state changes in real time (polling mode)
- Wait -- Block until a file is unlocked (useful in build scripts)
- Multiple output formats: table (default), JSON, CSV
- Recursive directory scanning with
-r - PID / process name filtering for targeted kills
git clone https://github.com/sheepla/wholock.git
cd wholock
cargo install --path .
Download the latest wholock.exe from the Releases page and place it in a directory listed in your PATH.
# Find what is locking a file
wholock scan C:\path\to\file.txt
# Kill the process holding the lock
wholock kill C:\path\to\file.txt
# Wait until a file is unlocked (for build scripts)
wholock wait C:\build\output\app.dll --timeout 30wholock [PATHS]... # shortcut for 'wholock scan'
wholock scan [OPTIONS] [PATHS]...
wholock kill [OPTIONS] [PATHS]...
wholock watch [OPTIONS] [PATHS]...
wholock wait [OPTIONS] [PATHS]...
When no subcommand is given, wholock behaves like wholock scan.
| Option | Description |
|---|---|
-r, --recursive |
Scan directories recursively |
--format <FORMAT> |
Output format: table (default), json, csv |
-v, --verbose |
Enable verbose output |
-q, --quiet |
Suppress non-essential output |
List processes that are locking the specified files.
wholock scan <PATHS>... [-r] [--format json|table|csv]
PS> wholock scan C:\project\build\app.dll
โญโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโฎ
โ PID โ PROCESS โ USER โ FILES โ
โโโโโโโโชโโโโโโโโโโโโโชโโโโโโโโโโโโโโชโโโโโโโโโโโก
โ 4512 โ app.exe โ DESKTOP\me โ app.dll โ
โฐโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโฏ
PS> wholock scan --format json C:\project\build\app.dll
{
"target_paths": [
"C:\\project\\build\\app.dll"
],
"scanned_at": "2026-07-21T11:38:48.714Z",
"processes": [
{
"pid": 4512,
"process_name": "app.exe",
"user": "DESKTOP\\me",
"locked_files": [
"C:\\project\\build\\app.dll"
],
"is_system_process": false,
"accessible": true
}
]
}
PS> wholock scan --format csv C:\project\build\app.dll
pid,process_name,user,locked_files,is_system_process,accessible
4512,app.exe,DESKTOP\me,C:\project\build\app.dll,false,true
Terminate processes that are locking the specified files.
wholock kill <PATHS>... [-r] [--pid <PID>]... [--name <NAME>]... [-i] [-y]
| Option | Description |
|---|---|
--pid <PID> |
Only kill this process (repeatable) |
--name <NAME> |
Only kill processes matching this name (repeatable) |
-i, --interactive |
Show a multi-select UI to choose which processes to kill |
-y, --yes |
Skip all confirmation prompts (for scripted use) |
# Kill all processes locking a file (with confirmation)
wholock kill C:\project\build\app.dll
# Kill only a specific PID
wholock kill C:\project\build\app.dll --pid 4512
# Interactive selection
wholock kill C:\project\build\app.dll --interactive
# Non-interactive (scripted)
wholock kill C:\project\build\app.dll -yMonitor lock state changes in real time. Prints LOCKED / UNLOCKED events when processes acquire or release locks.
wholock watch <PATHS>... [-r] [--interval <MS>] [--format json|table|csv]
| Option | Description |
|---|---|
--interval <MS> |
Polling interval in milliseconds (default: 1000) |
Press Ctrl+C to stop watching.
PS> wholock watch C:\project\build\app.dll --interval 500
โญโโโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโฎ
โ EVENT โ PID โ PROCESS โ USER โ FILES โ
โโโโโโโโโโโโชโโโโโโโชโโโโโโโโโโโชโโโโโโโโโโโโโโชโโโโโโโโโโโก
โ LOCKED โ 4512 โ app.exe โ DESKTOP\me โ app.dll โ
โฐโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโฏ
โญโโโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโฎ
โ EVENT โ PID โ PROCESS โ USER โ FILES โ
โโโโโโโโโโโโชโโโโโโโชโโโโโโโโโโโชโโโโโโโโโโโโโโชโโโโโโโโโโโก
โ UNLOCKED โ 4512 โ app.exe โ DESKTOP\me โ app.dll โ
โฐโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโฏ
JSON output uses JSON Lines format (one JSON object per line).
Block until the specified files are unlocked. Returns exit code 0 on success, non-zero on timeout.
wholock wait <PATHS>... [-r] [--timeout <SECONDS>]
| Option | Description |
|---|---|
--timeout <SECS> |
Maximum wait time in seconds. Omit to wait indefinitely. |
# Build script: wait for another process to release a DLL before overwriting
wholock wait C:\build\output\lib.dll --timeout 30
if ($LASTEXITCODE -eq 0) {
Copy-Item -Force new_lib.dll C:\build\output\lib.dll
} else {
Write-Error "Timed out waiting for lock release"
}Some processes run under different user accounts or elevated privileges. If wholock cannot access certain processes, it will indicate this with partial information. To detect all processes, run wholock as Administrator:
# Run as Administrator
wholock scan C:\Windows\System32\somefile.dll
MIT