Skip to main content

reg.exe query to pandas DataFrame

pip install getregdf

Tested against Windows 10 / Python 3.10 / Anaconda

This code provides a way to execute multiple registry queries using reg.exe and obtain the results in a structured DataFrame format. It abstracts the process of querying the registry and provides additional functionalities through the custom modules and functions used.

It's interesting for people who need to programmatically retrieve registry information from Windows systems because it allows them to automate the retrieval of registry data and process it in a structured manner using the powerful data manipulation capabilities of Pandas. They can analyze the retrieved registry information, perform further computations or transformations, and integrate it into their workflows or applications.

Calling the function in Python:

reg_query2df(
    regquerys,
    bufsize=2048,
    timeout=30000000,
    max_threads=5,
    timeout_check_sleep=1.0,
    convert_to_string=True,
):
    r"""
    Executes registry queries and returns the results as a DataFrame.

    Args:
        regquerys (str or list): A single registry query string or a list of query strings.
        bufsize (int, optional): Buffer size for subprocess communication. Defaults to 2048.
        timeout (int, optional): Timeout value for the subprocess execution. Defaults to 30000000.
        max_threads (int, optional): Maximum number of threads to use for subprocess execution. Defaults to 5.
        timeout_check_sleep (int, float, optional): Sleep duration between timeout checks. Defaults to 1.0.
        convert_to_string (int, bool, optional): Convert data from bytes (stdout) to string. Defaults to True

    Returns:
        pandas.DataFrame: A DataFrame containing the results of the registry queries.

    Raises:
        None

    Example usage:
        reg_query2df(
            regquerys=[
                "HKEY_USERS",
                r"HKEY_USERS\S-1-5-18",
                r"HKEY_USERS\S-1-5-21-2954889181-1639616918-2495923365-1001\EUDC",
            ],
            bufsize=2048,
            timeout=30000000,
            max_threads=5,
            timeout_check_sleep=1,
        )

    # print(df[:10].to_string())
    #                                                                        aa_regkey     aa_key aa_type                                                  aa_value  aa_id
    # 0                                                            HKEY_USERS\.DEFAULT                                                                                   0
    # 1                                                  HKEY_USERS\.DEFAULT\AppEvents                                                                                   0
    # 2                                      HKEY_USERS\.DEFAULT\AppEvents\EventLabels                                                                                   0
    # 3                       HKEY_USERS\.DEFAULT\AppEvents\EventLabels\MirrorFinished  (Default)  REG_SZ                                           Mirror Finished      0
    # 4                                          HKEY_USERS\.DEFAULT\AppEvents\Schemes                                                                                   0
    # 5                                     HKEY_USERS\.DEFAULT\AppEvents\Schemes\Apps                                                                                   0
    # 6                          HKEY_USERS\.DEFAULT\AppEvents\Schemes\Apps\WinHTTrack  (Default)  REG_SZ                                 WinHTTrack Website Copier      0
    # 7           HKEY_USERS\.DEFAULT\AppEvents\Schemes\Apps\WinHTTrack\MirrorFinished                                                                                   0
    # 8  HKEY_USERS\.DEFAULT\AppEvents\Schemes\Apps\WinHTTrack\MirrorFinished\.Current  (Default)  REG_SZ    C:\Program Files\WinHTTrack\html\server\sfx\silent.wav      0
    # 9  HKEY_USERS\.DEFAULT\AppEvents\Schemes\Apps\WinHTTrack\MirrorFinished\.Default  (Default)  REG_SZ  C:\Program Files\WinHTTrack\html\server\sfx\finished.wav      0

    # Slower than the first one: https://github.com/hansalemaos/a_pandas_ex_reg2df
    # But key, type, and value are in separated columns
	
# HKEY_CLASSES_ROOT (HKCR): This key contains file association and COM object registration information.
# HKEY_CURRENT_USER (HKCU): This key stores configuration information for the currently logged-in user.
# HKEY_LOCAL_MACHINE (HKLM): This key contains system-wide configuration settings and information for all users.
# HKEY_USERS (HKU): This key contains user-specific configuration settings for each user profile on the computer.
# HKEY_CURRENT_CONFIG (HKCC): This key provides access to the current hardware profile being used by the computer.


from getregdf import reg_query2df

df = reg_query2df(
    regquerys=[
        "HKEY_USERS",
        r"HKEY_CLASSES_ROOT",
        r"HKEY_LOCAL_MACHINE",
        r"HKEY_USERS",
        r"HKEY_CURRENT_CONFIG",
    ],
    bufsize=2048 * 100,
    timeout=30000000,
    max_threads=5,
    timeout_check_sleep=1,
)
df.to_pickle("c:\\myregexported.pkl")	

Metadata

Release files for getregdf 0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for getregdf 0.10
File Size Uploaded Provenance Actions
getregdf-0.10.tar.gz 6.7 kB Without provenance Details for getregdf-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for getregdf 0.10
File Interpreter ABI Platform Actions
getregdf-0.10-py3-none-any.whl Python 3 none any Details for getregdf-0.10-py3-none-any.whl

Total release size: 15.9 kB

Release files / getregdf-0.10.tar.gz

Download URL getregdf-0.10.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bb951af0c72853cbfa03131c9ce7f1abc34fe2f30ddc2f2c32b7cf770efcef69
BLAKE2b-256 checksum
How to use checksums
2eccf5504097decdb9e9efce7d535dd0a60592fbbcfb2c97117d0aa7f4f144f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / getregdf-0.10-py3-none-any.whl

Download URL getregdf-0.10-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f02c55290f748f307e9e11876bf0e0cf42e761ccd268140994db70e438a07bc
BLAKE2b-256 checksum
How to use checksums
eaa14cf3bf95fdc27ddc3bdc1c06bbaab9e3dfb8582d942610ca61b248f8a541
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for getregdf 0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page