https://github.com/liamsennitt/registrypol
Windows Registry Policy parser and emitter for Python
https://github.com/liamsennitt/registrypol
python windows
Last synced: about 2 months ago
JSON representation
Windows Registry Policy parser and emitter for Python
- Host: GitHub
- URL: https://github.com/liamsennitt/registrypol
- Owner: liamsennitt
- License: apache-2.0
- Created: 2020-11-22T13:13:18.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2026-05-05T21:54:48.000Z (2 months ago)
- Last Synced: 2026-05-05T23:31:42.754Z (2 months ago)
- Topics: python, windows
- Language: Python
- Homepage:
- Size: 92.8 KB
- Stars: 4
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RegistryPol
[](https://github.com/liamsennitt/registrypol/actions/workflows/build.yml)
[](https://pypi.org/project/registrypol/)
[](LICENSE)
The `registrypol` module allows you to easily parse and create Windows Registry Policy files in Python.
## Installation
To install the `registrypol` module via pip, run the command:
```console
$ pip install registrypol
```
## Usage
Start by importing the `registrypol` module.
```python
import registrypol
```
The function `registrypol.load`, loads an registry policy file.
```python
with open('registry.pol', 'rb') as file:
registrypol.load(file)
```
In addition to loading an existing registry policy, policies created using the relevant Values can be dumped to a file using the `registrypol.dump` function.
```python
with open('registry.pol', 'wb') as file:
registrypol.dump(policy, file)
```
### RegistryValue
To create a registry value as part of an registry policy, a `registrypol.values.RegistryValue` must be created.
```python
from registrypol.values import RegistryValue
value = RegistryValue(
key='Software\Policies\Microsoft\Windows\SrpV2\Exe',
value='EnforcementMode',
type='REG_DWORD',
size=4,
data=b'\x01\x00\x00\x00'
)
```
### RegistryPolicy
To create an registry policy one or more registry values must be created as described above.
These values can then be used to create an `registrypol.policy.RegistryPolicy`.
```python
from registrypol.policy import RegistryPolicy
policy = RegistryPolicy(
values=[
value
]
)
```