restartmgr
Python ctypes bindings for the Windows Restart Manager API rstrtmgr.dll). Find out which processes are locking a file - and optionally shut them down and restart them - all from pure Python, no C extension required.
Windows only - calls
rstrtmgr.dlldirectly viactypes. Zero runtime dependencies.
Installation
uv add restartmgr
or
pip install restartmgr
Python 3.12+ and Windows are required.
Quick start
Which processes lock a file?
from pathlib import Path
from restartmgr import who_locks
lockers = who_locks(Path(r"C:\path\to\locked_file.txt"))
for p in lockers:
print(f"PID {p.pid} {p.app_name} ({p.app_type.name})")
Detailed result with reboot reason
from restartmgr import get_locking_processes
result = get_locking_processes(r"C:\file_a.txt", r"C:\file_b.txt")
print(f"Reboot reason: {result.reboot_reason.name}")
for p in result.processes:
print(f" {p.pid} {p.app_name} restartable={p.restartable}")
Full session lifecycle
from restartmgr import RmSession, RmShutdownType
with RmSession() as session:
session.register_files([r"C:\path\to\file.txt"])
# Query which processes hold a lock
infos, reboot_reason = session.get_list()
for info in infos:
print(info.Process.dwProcessId, info.strAppName)
# Shut down those processes
session.shutdown(
action_flags=RmShutdownType.FORCE_SHUTDOWN,
)
# ... do your work on the file ...
# Restart the previously shut-down processes
session.restart()
License
MIT - see LICENSE.
About Modding Forge
restartmgr was built for the Python tooling powering Modding Forge - a community dedicated to Skyrim modding. If you enjoy modding or want to connect with other modders, come say hi!
Metadata
Release files for restartmgr 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| restartmgr-1.0.1.tar.gz | 42.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| restartmgr-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.3 kB
Release files / restartmgr-1.0.1.tar.gz
| Download URL | restartmgr-1.0.1.tar.gz |
|---|---|
| Size | 42.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7dafe53dfebf387b9a56710e53c661613b35fea5bafc19346a4dddadd55daac2
|
|
BLAKE2b-256 checksum How to use checksums |
429cb634eaa695a7929bd82c7e5d0b30315fc37e409e3b3d6dd6bd8f2c9c9246
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / restartmgr-1.0.1-py3-none-any.whl
| Download URL | restartmgr-1.0.1-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf874dae1846d4c5c05b8caff72ff9542bfd098eb32f2916a8d7a63648410d2b
|
|
BLAKE2b-256 checksum How to use checksums |
fb19fc44bb74a95c6b5ac4ac0d005878c0c51f213ecc0dc36b2e560c27e8c9b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|