Win32_PrinterConfiguration - WMI sample in Python

The foundations for Manageability in Windows 7/2008/Vista/XP/2000 and Millennium Edition/'98 are Windows Management Instrumentation (WMI; formerly WBEM) and WMI extensions for Windows Driver Model (WDM).

ActiveXperts Network Monitor provides the ability to build monitor check routines based on WMI. ActiveXperts has collected more than a hundred WMI samples. You can use these samples as a base for new check routines you can write yourself.

On this site, you can find many WMI samples.


Win32_PrinterConfiguration

Description

The Win32_PrinterConfiguration WMI class defines the configuration for a printer device. This includes capabilities such as resolution, color, fonts, and orientation.

Example(s)

import win32com.client
def WMIDateStringToDate(dtmDate):
    strDateTime = ""
    if (dtmDate[4] == 0):
        strDateTime = dtmDate[5] + '/'
    else:
        strDateTime = dtmDate[4] + dtmDate[5] + '/'
    if (dtmDate[6] == 0):
        strDateTime = strDateTime + dtmDate[7] + '/'
    else:
        strDateTime = strDateTime + dtmDate[6] + dtmDate[7] + '/'
        strDateTime = strDateTime + dtmDate[0] + dtmDate[1] + dtmDate[2] + dtmDate[3] + " " + dtmDate[8] + dtmDate[9] + ":" + dtmDate[10] + dtmDate[11] +':' + dtmDate[12] + dtmDate[13]
    return strDateTime

strComputer = "."
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
colItems = objSWbemServices.ExecQuery("SELECT * FROM Win32_PrinterConfiguration")
for objItem in colItems:
    if objItem.BitsPerPel != None:
        print "BitsPerPel:" + ` objItem.BitsPerPel`
    if objItem.Caption != None:
        print "Caption:" + ` objItem.Caption`
    if objItem.Collate != None:
        print "Collate:" + ` objItem.Collate`
    if objItem.Color != None:
        print "Color:" + ` objItem.Color`
    if objItem.Copies != None:
        print "Copies:" + ` objItem.Copies`
    if objItem.Description != None:
        print "Description:" + ` objItem.Description`
    if objItem.DeviceName != None:
        print "DeviceName:" + ` objItem.DeviceName`
    if objItem.DisplayFlags != None:
        print "DisplayFlags:" + ` objItem.DisplayFlags`
    if objItem.DisplayFrequency != None:
        print "DisplayFrequency:" + ` objItem.DisplayFrequency`
    if objItem.DitherType != None:
        print "DitherType:" + ` objItem.DitherType`
    if objItem.DriverVersion != None:
        print "DriverVersion:" + ` objItem.DriverVersion`
    if objItem.Duplex != None:
        print "Duplex:" + ` objItem.Duplex`
    if objItem.FormName != None:
        print "FormName:" + ` objItem.FormName`
    if objItem.HorizontalResolution != None:
        print "HorizontalResolution:" + ` objItem.HorizontalResolution`
    if objItem.ICMIntent != None:
        print "ICMIntent:" + ` objItem.ICMIntent`
    if objItem.ICMMethod != None:
        print "ICMMethod:" + ` objItem.ICMMethod`
    if objItem.LogPixels != None:
        print "LogPixels:" + ` objItem.LogPixels`
    if objItem.MediaType != None:
        print "MediaType:" + ` objItem.MediaType`
    if objItem.Name != None:
        print "Name:" + ` objItem.Name`
    if objItem.Orientation != None:
        print "Orientation:" + ` objItem.Orientation`
    if objItem.PaperLength != None:
        print "PaperLength:" + ` objItem.PaperLength`
    if objItem.PaperSize != None:
        print "PaperSize:" + ` objItem.PaperSize`
    if objItem.PaperWidth != None:
        print "PaperWidth:" + ` objItem.PaperWidth`
    if objItem.PelsHeight != None:
        print "PelsHeight:" + ` objItem.PelsHeight`
    if objItem.PelsWidth != None:
        print "PelsWidth:" + ` objItem.PelsWidth`
    if objItem.PrintQuality != None:
        print "PrintQuality:" + ` objItem.PrintQuality`
    if objItem.Scale != None:
        print "Scale:" + ` objItem.Scale`
    if objItem.SettingID != None:
        print "SettingID:" + ` objItem.SettingID`
    if objItem.SpecificationVersion != None:
        print "SpecificationVersion:" + ` objItem.SpecificationVersion`
    if objItem.TTOption != None:
        print "TTOption:" + ` objItem.TTOption`
    if objItem.VerticalResolution != None:
        print "VerticalResolution:" + ` objItem.VerticalResolution`
    if objItem.XResolution != None:
        print "XResolution:" + ` objItem.XResolution`
    if objItem.YResolution != None:
        print "YResolution:" + ` objItem.YResolution`