Skip to main content

Get Manufacturer (Windows)

Description

The get_manufacturer_windows function retrieves the manufacturer of the system on Windows. It uses the wmi module to query the system for processor details and returns the manufacturer name after parsing it. If an error occurs, it returns an empty string and a status code of 1.

Function Signature:

def get_manufacturer_windows() -> tuple[str, int]:

Parameters

This function does not take any parameters.

Returns

  • tuple: A tuple containing two values:
    • str: The manufacturer name (e.g., "Dell", "HP").
    • int: A status code indicating the result of the operation (e.g., 0 for success, 1 for failure).

Example Usage

Here’s an example of how the function works:

manufacturer, status = get_manufacturer_windows()
print(f"Manufacturer: {manufacturer}, Status: {status}")

Example Output:

Manufacturer: Dell, Status: 0

Code

def get_manufacturer_windows() -> tuple[str, int]:
try:
import wmi
w = wmi.WMI()
for processor in w.Win32_Processor():
return parse_manufacturer(processor.Manufacturer.strip()), 0
except Exception as e:
print(f"Exception in get_manufacturer_windows: {e}")
return "", 1

return "", 1

Errors and Exceptions

  • If an error occurs while querying the system for processor details or parsing the manufacturer, an exception is caught, and the function returns an empty string and a failure status code (1).

Notes

This function is platform-specific and is designed to work on Windows systems. It uses the wmi module to fetch details about the system's processor. You will need to ensure that the wmi package is installed to use this function.