Metadata-Version: 2.4
Name: unlatch
Version: 0.7.0
Summary: See which processes hold a file or folder on Windows, and free it.
Keywords: file-lock,locksmith,handles,windows,explorer,unlock
Author: Mike Hill
Author-email: Mike Hill <mike@mikejhill.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Win32 (MS Windows)
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Filesystems
Classifier: Topic :: Utilities
Requires-Dist: psutil>=7.2.2
Requires-Dist: pyside6-essentials>=6.12.0
Requires-Python: >=3.13
Project-URL: Homepage, https://github.com/mikejhill/unlatch
Project-URL: Documentation, https://github.com/mikejhill/unlatch#readme
Project-URL: Changelog, https://github.com/mikejhill/unlatch/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/mikejhill/unlatch/issues
Description-Content-Type: text/markdown

# Unlatch

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mikejhill/unlatch/main/docs/brand/wordmark-dark.png">
  <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/mikejhill/unlatch/main/docs/brand/wordmark-light.png">
  <img
    src="https://raw.githubusercontent.com/mikejhill/unlatch/main/docs/brand/wordmark-light.png"
    alt="Unlatch" width="280">
</picture>

[![CI](https://github.com/mikejhill/unlatch/actions/workflows/ci.yml/badge.svg)](https://github.com/mikejhill/unlatch/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/unlatch.svg)](https://pypi.org/project/unlatch/)
[![Release](https://github.com/mikejhill/unlatch/actions/workflows/release.yml/badge.svg)](https://github.com/mikejhill/unlatch/actions/workflows/release.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mikejhill/unlatch/blob/main/LICENSE)

"The action can't be completed because the file is open in another program."
Unlatch tells you which program, and lets it go.

Right-click a file or folder, choose **Check locks with Unlatch**, and Unlatch
lists every process that has it open, has a working directory inside it, or
has it loaded as a program or DLL. End the process in one click, or, as an
advanced step, close just the handle that blocks you.

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mikejhill/unlatch/main/docs/images/window-dark.png">
  <img
    src="https://raw.githubusercontent.com/mikejhill/unlatch/main/docs/images/window-light.png"
    alt="The Unlatch window: two items held by three processes, each with its
      PID, user, and what it holds"
    width="760">
</picture>

## Features

- **Finds every kind of hold**: open file and folder handles, working
  directories, loaded DLLs, and program files, for a file, a folder and
  everything inside it, or several items at once. Works on local drives,
  volumes mounted in folders, network shares, and WSL paths.
- **Explorer integration**: a per-user **Check locks with Unlatch** entry for
  files, folders, folder backgrounds, and drives. Selecting several items opens
  one window.
- **Safe actions**: before ending a process or closing a handle, Unlatch checks
  that the PID and handle still belong to what you saw, so a stale row never
  ends an unrelated program.
- **Honest about blind spots**: when not elevated it says how many processes
  it could not inspect and offers **Restart as administrator**.
- **Scriptable**: `unlatch scan --json`, `unlatch check` (exit code 3 when
  held), `unlatch kill`, and `unlatch release`.
- **Fast**: one read of the system handle table, filtered before any expensive
  call; a typical scan takes well under a second.

Unlatch fills the same need as Microsoft PowerToys File Locksmith. It is an
independent Python implementation that installs on its own.

## Install

Requires Windows 10 or later and Python 3.13 or later.

```powershell
uv tool install unlatch
```

Or with pip: `pip install unlatch`. Wheels with build provenance are also
attached to each [GitHub release](https://github.com/mikejhill/unlatch/releases).

### Explorer Menu

Unlatch never changes the File Explorer menu on its own. Add **Check locks with
Unlatch** for your account (no administrator rights needed) with:

```powershell
unlatch shell install
```

On Windows 11 the entry is under **Show more options** (Shift+F10), like other
classic menu entries.

| Do this | Run |
| --- | --- |
| Add or update the entry | `unlatch shell install` |
| See whether it is installed, current, or has leftovers | `unlatch shell status` |
| Remove it, including entries older versions added | `unlatch shell uninstall` |

After `uv tool upgrade unlatch`, run `unlatch shell status`; if it says the
entry is out of date, run `unlatch shell install` again. Python installers
cannot run code when a package is removed, so remove the entry first:

```powershell
unlatch shell uninstall
uv tool uninstall unlatch
```

Unlatch records every registry location any version has used, so `install` and
`uninstall` always clear entries left behind by older versions.

## Use

| Do this | Run |
| --- | --- |
| Open the window | `unlatch` or `unlatch-gui` (no console) |
| Open the window on paths | `unlatch gui C:\path\file.txt C:\path\folder` |
| List holders | `unlatch scan C:\path\file.txt` |
| List holders as JSON | `unlatch scan --json C:\path\folder` |
| Test in a script | `unlatch check C:\path\file.txt` (0 free, 3 held, 1 error) |
| End every holder | `unlatch kill C:\path\file.txt` (asks first; `--yes` to skip) |
| Close the blocking handles only | `unlatch release C:\path\file.txt` (asks first) |

In the window, **Add…** opens one picker for files or a folder (use **Add this
folder** for the folder you are in), or drop files and folders onto the window.
Select one or more rows (Ctrl or Shift) and press **Delete** to end the
processes that hold them. **F5** checks again, **Ctrl+F** filters, **Ctrl+C**
copies the selected rows, and **Ctrl+Plus** or **Ctrl+Minus** expands or
collapses every process. Right-click a row to copy a cell or its details, open
the file location, or close a handle.

Each handle row shows its handle value (as in Process Explorer, so two handles
on the same file are told apart) and what it may do with the item, such as
**Read, write**. Hover a row, or use **Copy details**, for the full access mask
and every right in it. Windows does not reveal the sharing mode a program chose,
which is what decides whether a handle blocks a rename or delete.

**Close this handle (advanced)** closes the handle inside the program, as if the
program had closed it, without telling the program. The item is then free
unless something else holds it, but the program still thinks it is open: its
next use of the handle fails, or reaches a different file if Windows reuses the
number, so it may lose unsaved work, damage the file, or crash. Ending the
process is the safer choice.

## Limits

- Without administrator rights, processes of other users and elevated
  processes are not visible. Unlatch counts them and offers to restart
  elevated.
- Kernel-mode handles (including files opened by other computers over SMB,
  which belong to the System process) and memory-mapped files whose handle was
  closed are not reported.

## Documentation

| Document | Contents |
| --- | --- |
| [Philosophy and architecture](docs/design/philosophy.md) | Purpose, principles, and how a hold is found |
| [UX contract](docs/design/ux-contract.md) | Promises the window keeps, each proven by a test |
| [Brand](docs/brand/README.md) | Name, icon, and asset rules |
| [Testing](docs/testing.md) | Test suites, markers, and mutation testing |
| [Releasing](docs/releasing.md) | How versions and releases are produced |
| [Decisions](docs/decisions/README.md) | Why Unlatch is built the way it is |
| [All documentation](docs/README.md) | Index of everything under `docs/` |
| [Contributing](CONTRIBUTING.md) | Setup and the quality gate |

## License

MIT. See [LICENSE](LICENSE).
