util_windows_check

Path: /utilities/util_windows_check.py

Overview

This module provides functionality to detect and enforce that the host operating system is Windows 11 Home or Professional by reading relevant registry values.

Purpose & Use Cases

Validate OS compatibility before running installation or setup scripts in Talon.

Retrieve and log the Windows edition for conditional logic in other components.

Dependencies

Python standard library: sys, winreg

Raven Development Team utilities: util_logger, util_error_popup

Configuration & Parameters

Parameter Type Description Default
None N/A No configurable parameters in this module N/A

Usage Example

python util_windows_check.py

Behavior & Implementation

When executed, the module calls check_windows_11_home_or_pro, which in turn uses a helper _read_registry_value(name) to read ProductName and CurrentBuildNumber from HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion. It determines if the OS is Windows 11 (or Windows 10 with build ≥ 22000), then extracts “Home” or “Professional” from the product name. On success, it logs the detected edition and returns it.

Error Handling

If running on a non-Windows platform, or if registry reads fail, or if the edition is unsupported, the module shows a blocking error dialog via show_error_popup and exits the process. Unexpected exceptions during registry access are caught, logged, and surfaced through the same popup mechanism.

Security Considerations

The module only performs read operations on HKLM; no write permissions are required. It relies on Win32 API registry access with KEY_WOW64_64KEY when available. User confirmation is required to acknowledge unsupported OS scenarios.

Logging

Uses the Raven Development Team’s util_logger at INFO level to report detected OS and edition, and at ERROR or EXCEPTION levels for failures. Example log: “Detected OS: Windows 11 Home (build 22621); edition: Home”.

Testing & Validation

Unit tests can mock winreg.OpenKey to supply fake ProductName and CurrentBuildNumber values. Manually, run the script on supported and unsupported Windows versions to verify correct popup behavior and exit codes.

Author

Author: Raven Development Team