Win32_POTSModem - 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_POTSModem

Description

The Win32_PortResource WMI class represents an I/O port on a Windows computer system.

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_POTSModem")
for objItem in colItems:
    if objItem.AnswerMode != None:
        print "AnswerMode:" + ` objItem.AnswerMode`
    if objItem.AttachedTo != None:
        print "AttachedTo:" + ` objItem.AttachedTo`
    if objItem.Availability != None:
        print "Availability:" + ` objItem.Availability`
    if objItem.BlindOff != None:
        print "BlindOff:" + ` objItem.BlindOff`
    if objItem.BlindOn != None:
        print "BlindOn:" + ` objItem.BlindOn`
    if objItem.Caption != None:
        print "Caption:" + ` objItem.Caption`
    if objItem.CompatibilityFlags != None:
        print "CompatibilityFlags:" + ` objItem.CompatibilityFlags`
    if objItem.CompressionInfo != None:
        print "CompressionInfo:" + ` objItem.CompressionInfo`
    if objItem.CompressionOff != None:
        print "CompressionOff:" + ` objItem.CompressionOff`
    if objItem.CompressionOn != None:
        print "CompressionOn:" + ` objItem.CompressionOn`
    if objItem.ConfigManagerErrorCode != None:
        print "ConfigManagerErrorCode:" + ` objItem.ConfigManagerErrorCode`
    if objItem.ConfigManagerUserConfig != None:
        print "ConfigManagerUserConfig:" + ` objItem.ConfigManagerUserConfig`
    if objItem.ConfigurationDialog != None:
        print "ConfigurationDialog:" + ` objItem.ConfigurationDialog`
    print "CountriesSupported:"
    strList = " "
    try :
        for objElem in objItem.CountriesSupported :
            strList = strList + `objElem` + ","
    except:
        strList = strList + 'null'
    print strList
    if objItem.CountrySelected != None:
        print "CountrySelected:" + ` objItem.CountrySelected`
    if objItem.CreationClassName != None:
        print "CreationClassName:" + ` objItem.CreationClassName`
    print "CurrentPasswords:"
    strList = " "
    try :
        for objElem in objItem.CurrentPasswords :
            strList = strList + `objElem` + ","
    except:
        strList = strList + 'null'
    print strList
    print "DCB:"
    strList = " "
    try :
        for objElem in objItem.DCB :
            strList = strList + `objElem` + ","
    except:
        strList = strList + 'null'
    print strList
    print "Default:"
    strList = " "
    try :
        for objElem in objItem.Default :
            strList = strList + `objElem` + ","
    except:
        strList = strList + 'null'
    print strList
    if objItem.Description != None:
        print "Description:" + ` objItem.Description`
    if objItem.DeviceID != None:
        print "DeviceID:" + ` objItem.DeviceID`
    if objItem.DeviceLoader != None:
        print "DeviceLoader:" + ` objItem.DeviceLoader`
    if objItem.DeviceType != None:
        print "DeviceType:" + ` objItem.DeviceType`
    if objItem.DialType != None:
        print "DialType:" + ` objItem.DialType`
    if objItem.DriverDate != None:
        print "DriverDate:" + WMIDateStringToDate(objItem.DriverDate)
    if objItem.ErrorCleared != None:
        print "ErrorCleared:" + ` objItem.ErrorCleared`
    if objItem.ErrorControlForced != None:
        print "ErrorControlForced:" + ` objItem.ErrorControlForced`
    if objItem.ErrorControlInfo != None:
        print "ErrorControlInfo:" + ` objItem.ErrorControlInfo`
    if objItem.ErrorControlOff != None:
        print "ErrorControlOff:" + ` objItem.ErrorControlOff`
    if objItem.ErrorControlOn != None:
        print "ErrorControlOn:" + ` objItem.ErrorControlOn`
    if objItem.ErrorDescription != None:
        print "ErrorDescription:" + ` objItem.ErrorDescription`
    if objItem.FlowControlHard != None:
        print "FlowControlHard:" + ` objItem.FlowControlHard`
    if objItem.FlowControlOff != None:
        print "FlowControlOff:" + ` objItem.FlowControlOff`
    if objItem.FlowControlSoft != None:
        print "FlowControlSoft:" + ` objItem.FlowControlSoft`
    if objItem.InactivityScale != None:
        print "InactivityScale:" + ` objItem.InactivityScale`
    if objItem.InactivityTimeout != None:
        print "InactivityTimeout:" + ` objItem.InactivityTimeout`
    if objItem.Index != None:
        print "Index:" + ` objItem.Index`
    if objItem.InstallDate != None:
        print "InstallDate:" + WMIDateStringToDate(objItem.InstallDate)
    if objItem.LastErrorCode != None:
        print "LastErrorCode:" + ` objItem.LastErrorCode`
    if objItem.MaxBaudRateToPhone != None:
        print "MaxBaudRateToPhone:" + ` objItem.MaxBaudRateToPhone`
    if objItem.MaxBaudRateToSerialPort != None:
        print "MaxBaudRateToSerialPort:" + ` objItem.MaxBaudRateToSerialPort`
    if objItem.MaxNumberOfPasswords != None:
        print "MaxNumberOfPasswords:" + ` objItem.MaxNumberOfPasswords`
    if objItem.Model != None:
        print "Model:" + ` objItem.Model`
    if objItem.ModemInfPath != None:
        print "ModemInfPath:" + ` objItem.ModemInfPath`
    if objItem.ModemInfSection != None:
        print "ModemInfSection:" + ` objItem.ModemInfSection`
    if objItem.ModulationBell != None:
        print "ModulationBell:" + ` objItem.ModulationBell`
    if objItem.ModulationCCITT != None:
        print "ModulationCCITT:" + ` objItem.ModulationCCITT`
    if objItem.ModulationScheme != None:
        print "ModulationScheme:" + ` objItem.ModulationScheme`
    if objItem.Name != None:
        print "Name:" + ` objItem.Name`
    if objItem.PNPDeviceID != None:
        print "PNPDeviceID:" + ` objItem.PNPDeviceID`
    if objItem.PortSubClass != None:
        print "PortSubClass:" + ` objItem.PortSubClass`
    print "PowerManagementCapabilities:"
    strList = " "
    try :
        for objElem in objItem.PowerManagementCapabilities :
            strList = strList + `objElem` + ","
    except:
        strList = strList + 'null'
    print strList
    if objItem.PowerManagementSupported != None:
        print "PowerManagementSupported:" + ` objItem.PowerManagementSupported`
    if objItem.Prefix != None:
        print "Prefix:" + ` objItem.Prefix`
    print "Properties:"
    strList = " "
    try :
        for objElem in objItem.Properties :
            strList = strList + `objElem` + ","
    except:
        strList = strList + 'null'
    print strList
    if objItem.ProviderName != None:
        print "ProviderName:" + ` objItem.ProviderName`
    if objItem.Pulse != None:
        print "Pulse:" + ` objItem.Pulse`
    if objItem.Reset != None:
        print "Reset:" + ` objItem.Reset`
    if objItem.ResponsesKeyName != None:
        print "ResponsesKeyName:" + ` objItem.ResponsesKeyName`
    if objItem.RingsBeforeAnswer != None:
        print "RingsBeforeAnswer:" + ` objItem.RingsBeforeAnswer`
    if objItem.SpeakerModeDial != None:
        print "SpeakerModeDial:" + ` objItem.SpeakerModeDial`
    if objItem.SpeakerModeOff != None:
        print "SpeakerModeOff:" + ` objItem.SpeakerModeOff`
    if objItem.SpeakerModeOn != None:
        print "SpeakerModeOn:" + ` objItem.SpeakerModeOn`
    if objItem.SpeakerModeSetup != None:
        print "SpeakerModeSetup:" + ` objItem.SpeakerModeSetup`
    if objItem.SpeakerVolumeHigh != None:
        print "SpeakerVolumeHigh:" + ` objItem.SpeakerVolumeHigh`
    if objItem.SpeakerVolumeInfo != None:
        print "SpeakerVolumeInfo:" + ` objItem.SpeakerVolumeInfo`
    if objItem.SpeakerVolumeLow != None:
        print "SpeakerVolumeLow:" + ` objItem.SpeakerVolumeLow`
    if objItem.SpeakerVolumeMed != None:
        print "SpeakerVolumeMed:" + ` objItem.SpeakerVolumeMed`
    if objItem.Status != None:
        print "Status:" + ` objItem.Status`
    if objItem.StatusInfo != None:
        print "StatusInfo:" + ` objItem.StatusInfo`
    if objItem.StringFormat != None:
        print "StringFormat:" + ` objItem.StringFormat`
    if objItem.SupportsCallback != None:
        print "SupportsCallback:" + ` objItem.SupportsCallback`
    if objItem.SupportsSynchronousConnect != None:
        print "SupportsSynchronousConnect:" + ` objItem.SupportsSynchronousConnect`
    if objItem.SystemCreationClassName != None:
        print "SystemCreationClassName:" + ` objItem.SystemCreationClassName`
    if objItem.SystemName != None:
        print "SystemName:" + ` objItem.SystemName`
    if objItem.Terminator != None:
        print "Terminator:" + ` objItem.Terminator`
    if objItem.TimeOfLastReset != None:
        print "TimeOfLastReset:" + WMIDateStringToDate(objItem.TimeOfLastReset)
    if objItem.Tone != None:
        print "Tone:" + ` objItem.Tone`
    if objItem.VoiceSwitchFeature != None:
        print "VoiceSwitchFeature:" + ` objItem.VoiceSwitchFeature`