Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

sheepla/wholock

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

wholock

Find which processes are locking your files on Windows

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.

Features

  • 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

Installation

From source (requires Rust toolchain)

git clone https://github.com/sheepla/wholock.git
cd wholock
cargo install --path .

Download binary

Download the latest wholock.exe from the Releases page and place it in a directory listed in your PATH.

Quick Start

# 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 30

Usage

General

wholock [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.

Common Options

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

wholock scan

List processes that are locking the specified files.

wholock scan <PATHS>... [-r] [--format json|table|csv]

Example -- table output (default)

PS> wholock scan C:\project\build\app.dll

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ PID  โ”† PROCESS    โ”† USER        โ”† FILES    โ”‚
โ•žโ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ก
โ”‚ 4512 โ”† app.exe    โ”† DESKTOP\me  โ”† app.dll  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Example -- JSON output

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
    }
  ]
}

Example -- CSV output

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

wholock kill

Terminate processes that are locking the specified files.

wholock kill <PATHS>... [-r] [--pid <PID>]... [--name <NAME>]... [-i] [-y]

Options

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)

Examples

# 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 -y

wholock watch

Monitor 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.

Example

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).


wholock wait

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.

Example

# 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"
}

Permissions

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

License

MIT

About

๐Ÿ”’ Find which processes are locking your files on Windows

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.