Skip to main content

a more pythonic way to access the windows registry as winreg

Project description


Version v2.0.4 as of 2020-08-01 see Changelog

travis_build license jupyter pypi

codecov better_code Maintainability Maintainability Code Coverage snyk

a more pythonic way to access the windows registry as winreg

command line interface is prepared - if someone needs to use it via commandline, give me a note.

automated tests, Travis Matrix, Documentation, Badges, etc. are managed with PizzaCutter (cookiecutter on steroids)

Python version required: 3.6.0 or newer

tested on linux “bionic” with python 3.6, 3.7, 3.8, 3.8-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64

100% code coverage, codestyle checking ,mypy static type checking ,tested under Linux, macOS, Windows, automatic daily builds and monitoring

Try it Online

You might try it right away in Jupyter Notebook by using the “launch binder” badge, or click here


>>> from lib_registry import *

>>> # Read a Value from the Registry
>>> key =  'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\S-1-5-20'
>>> get_value(key_name=key, value_name='ProfileImagePath')

>>> # Create a Key
>>> create_key(r'HKCU\\Software\\lib_registry_test')

>>> # Delete a Key
>>> delete_key(r'HKCU\\Software\\lib_registry_test')

>>> # Write a Value to the Registry
>>> create_key(r'HKCU\\Software\\lib_registry_test')
>>> set_value(key_name=r'HKCU\\Software\\lib_registry_test', value_name='test_name', value='test_string', value_type=REG_SZ)
>>> result = get_value(key_name=r'HKCU\\Software\\lib_registry_test', value_name='test_name')
>>> assert result == 'test_string'

>>> # Delete a Value from the Registry
>>> delete_value(key_name=r'HKCU\\Software\\lib_registry_test', value_name='test_name')
>>> delete_key(r'HKCU\\Software\\lib_registry_test')

>>> # Check if a key exists
>>> key_exist('HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\S-1-5-20'
>>> key_exist('HKEY_LOCAL_MACHINE\\Software\\DoesNotExist')

>>> # get the SIDs of all Windows users
>>> get_ls_user_sids()
['.DEFAULT', 'S-1-5-18', 'S-1-5-19', 'S-1-5-20', ...]

>>> # get the Username from SID
>>> get_username_from_sid(sid='S-1-5-20')

Usage from Commandline

Usage: lib_registry [OPTIONS] COMMAND [ARGS]...

  a more pythonic way to access the windows registry as winreg

  --version                     Show the version and exit.
  --traceback / --no-traceback  return traceback information on cli
  -h, --help                    Show this message and exit.

  info  get program informations

Installation and Upgrade

  • Before You start, its highly recommended to update pip and setup tools:
python -m pip --upgrade pip
python -m pip --upgrade setuptools
python -m pip --upgrade wheel
  • to install the latest release from PyPi via pip (recommended):
# install latest release from PyPi
python -m pip install --upgrade lib_registry

# test latest release from PyPi without installing (can be skipped)
python -m pip install lib_registry --install-option test
  • to install the latest development version from github via pip:
# normal install
python -m pip install --upgrade git+

# to test without installing (can be skipped)
python -m pip install git+ --install-option test

# to install and upgrade all dependencies regardless of version number
python -m pip install --upgrade git+ --upgrade-strategy eager
  • include it into Your requirements.txt:
# Insert following line in Your requirements.txt:
# for the latest Release on pypi:

# for the latest development version :
lib_registry @ git+

# to install and upgrade all modules mentioned in requirements.txt:
python -m pip install --upgrade -r /<path>/requirements.txt
  • to install the latest development version from source code:
# cd ~
$ git clone
$ cd lib_registry

# to test without installing (can be skipped)
python test

# normal install
python install
  • via makefile: makefiles are a very convenient way to install. Here we can do much more, like installing virtual environments, clean caches and so on.
# from Your shell's homedirectory:
$ git clone
$ cd lib_registry

# to run the tests:
$ make test

# to install the package
$ make install

# to clean the package
$ make clean

# uninstall the package
$ make uninstall


following modules will be automatically installed :

## Project Requirements
cli_exit_tools @ git+
fake_winreg @ git+


  • special thanks to “uncle bob” Robert C. Martin, especially for his books on “clean code” and “clean architecture”


I would love for you to fork and send me pull request for this project. - please Contribute


This software is licensed under the MIT license


  • new MAJOR version for incompatible API changes,
  • new MINOR version for added functionality in a backwards compatible manner
  • new PATCH version for backwards compatible bug fixes
  • test if caching of handles make sense, especially on network
  • documentation update
  • pathlib-like Interface
  • jupyter notebook update


2020-08-01: fix pypi deploy


2020-07-31: fix travis build


2020-07-29: feature release
  • use the new pizzacutter template
  • use cli_exit_tools


2020-07-16: feature release
  • fix cli test
  • enable traceback option on cli errors
  • corrected error in DeleteKey, missing_ok


2020-07-14 : feature release
  • fix for deploy on pypi
  • fix travis for pypi deploy testing


2020-07-13 : intermediate release
  • start to implement additional pathlib-like interface
  • implement fake-winreg to be able to develop and test under linux


2020-07-08 : patch release
  • new click CLI
  • use PizzaCutter Template
  • added jupyter notebook
  • reorganized modules and import
  • updated documentation


2019-09-02: strict mypy type checking, housekeeping


2019-04-10: initial PyPi release


2019-03-29: prevent import error when importing under linux


2019-03-28: Initial public release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lib-registry, version 2.0.4
Filename, size File type Python version Upload date Hashes
Filename, size lib_registry-2.0.4-py3-none-any.whl (17.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size lib_registry-2.0.4.tar.gz (20.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page