Skip to main content

Windows Registry related

Project description

lib_registry

Build Status Pypi Status Codecov Status Better Code snyk security

some convenience functions to access the windows registry - to be extended.

supports python 2.7 - python 3.7 and possibly other dialects.

100% code coverage, tested under Windows and Wine


Report Issues

Contribute

Pull Request

Code of Conduct


Installation and Upgrade

From source code:

# normal install
python setup.py install
# test without installing
python setup.py test

via pip latest Release:

# latest Release from pypi
pip install lib_registry

via pip latest Development Version:

# upgrade all dependencies regardless of version number (PREFERRED)
pip install --upgrade https://github.com/bitranox/lib_registry/archive/master.zip --upgrade-strategy eager
# normal install
pip install --upgrade https://github.com/bitranox/lib_registry/archive/master.zip
# test without installing
pip install --upgrade https://github.com/bitranox/lib_registry/archive/master.zip  --install-option test

via requirements.txt:

# Insert following line in Your requirements.txt:
# for the latest Release:
lib_registry
# for the latest Development Version :
https://github.com/bitranox/lib_registry/archive/master.zip

# to install and upgrade all modules mentioned in requirements.txt:
pip install --upgrade -r /<path>/requirements.txt

via python:

python -m pip install --upgrade lib_registry

Basic Usage

>>> 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')
'%systemroot%\\\\ServiceProfiles\\\\NetworkService'

>>> # 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'
True
>>> key_exist('HKEY_LOCAL_MACHINE\\Software\\DoesNotExist')
False

>>> # get the SID´s 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')
'NetworkService'

Acknowledgement

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

Contribute

I would love for you to fork and send me pull request for this project. Please contribute.

License

This software is licensed under the MIT license

See License file

Changelog

1.0.2

2019-04-10: initial PyPi release

1.0.1

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

1.0.0

2019-03-28: Initial public release

Project details


Release history Release notifications

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
lib_registry-1.0.2-py2-none-any.whl (7.1 kB) Copy SHA256 hash SHA256 Wheel py2
lib_registry-1.0.2.tar.gz (6.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page