Python ctypes bindings for the Windows Restart Manager API (rstrtmgr.dll)
Project description
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!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file restartmgr-1.0.1.tar.gz.
File metadata
- Download URL: restartmgr-1.0.1.tar.gz
- Upload date:
- Size: 42.8 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dafe53dfebf387b9a56710e53c661613b35fea5bafc19346a4dddadd55daac2
|
|
| MD5 |
1da9de59e35c6a80446e29aeeb55cf21
|
|
| BLAKE2b-256 |
429cb634eaa695a7929bd82c7e5d0b30315fc37e409e3b3d6dd6bd8f2c9c9246
|
File details
Details for the file restartmgr-1.0.1-py3-none-any.whl.
File metadata
- Download URL: restartmgr-1.0.1-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf874dae1846d4c5c05b8caff72ff9542bfd098eb32f2916a8d7a63648410d2b
|
|
| MD5 |
0889aa7f6da615c23a01d721e5bb363e
|
|
| BLAKE2b-256 |
fb19fc44bb74a95c6b5ac4ac0d005878c0c51f213ecc0dc36b2e560c27e8c9b4
|