Metadata-Version: 2.4
Name: unlatch
Version: 0.1.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)
[![Release](https://img.shields.io/github/v/release/mikejhill/unlatch)](https://github.com/mikejhill/unlatch/releases)
[![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 **What's holding this?**, 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.

![The Unlatch window listing two programs that hold a document: one with an open handle and one with it loaded as a module](https://raw.githubusercontent.com/mikejhill/unlatch/main/docs/images/window.png)

## 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.
- **Explorer integration**: a per-user **What's holding this?** 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 git+https://github.com/mikejhill/unlatch
```

Wheels are also attached to each [GitHub release](https://github.com/mikejhill/unlatch/releases)
(`uv tool install <wheel URL>`). Then add the Explorer menu entry:

```powershell
unlatch shell install
```

On Windows 11 the entry is under **Show more options** (Shift+F10), like other
classic menu entries. `unlatch shell uninstall` removes it.

## 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: **F5** scans again, **Delete** ends the selected process,
**Ctrl+F** filters, **Ctrl+C** copies details, and right-click offers **Open
file location** and **Release handle**. Drop files or folders onto the window
to add them.

Closing a handle without ending its program is the advanced option: the
program is not told, so it may lose data 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 |
| [Contributing](CONTRIBUTING.md) | Setup and the quality gate |

## License

MIT. See [LICENSE](LICENSE).
