Win32_POTSModem - WMI sample in JScript

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)

var wbemFlagReturnImmediately = 0x10;
var wbemFlagForwardOnly = 0x20;

var arrComputers = new Array("\localhost");
for (i = 0; i < arrComputers.length; i++) {
   WScript.Echo();
   WScript.Echo("==========================================");
   WScript.Echo("Computer: " + arrComputers[i]);
   WScript.Echo("==========================================");

   var objWMIService = GetObject("winmgmts:\\\\" + arrComputers[i] + "\\root\\CIMV2");
   var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_POTSModem", "WQL",
                                          wbemFlagReturnImmediately | wbemFlagForwardOnly);

   var enumItems = new Enumerator(colItems);
   for (; !enumItems.atEnd(); enumItems.moveNext()) {
      var objItem = enumItems.item();

      WScript.Echo("AnswerMode: " + objItem.AnswerMode);
      WScript.Echo("AttachedTo: " + objItem.AttachedTo);
      WScript.Echo("Availability: " + objItem.Availability);
      WScript.Echo("BlindOff: " + objItem.BlindOff);
      WScript.Echo("BlindOn: " + objItem.BlindOn);
      WScript.Echo("Caption: " + objItem.Caption);
      WScript.Echo("CompatibilityFlags: " + objItem.CompatibilityFlags);
      WScript.Echo("CompressionInfo: " + objItem.CompressionInfo);
      WScript.Echo("CompressionOff: " + objItem.CompressionOff);
      WScript.Echo("CompressionOn: " + objItem.CompressionOn);
      WScript.Echo("ConfigManagerErrorCode: " + objItem.ConfigManagerErrorCode);
      WScript.Echo("ConfigManagerUserConfig: " + objItem.ConfigManagerUserConfig);
      WScript.Echo("ConfigurationDialog: " + objItem.ConfigurationDialog);
      try { WScript.Echo("CountriesSupported: " + (objItem.CountriesSupported.toArray()).join(",")); }
         catch(e) { WScript.Echo("CountriesSupported: null"); }
      WScript.Echo("CountrySelected: " + objItem.CountrySelected);
      WScript.Echo("CreationClassName: " + objItem.CreationClassName);
      try { WScript.Echo("CurrentPasswords: " + (objItem.CurrentPasswords.toArray()).join(",")); }
         catch(e) { WScript.Echo("CurrentPasswords: null"); }
      try { WScript.Echo("DCB: " + (objItem.DCB.toArray()).join(",")); }
         catch(e) { WScript.Echo("DCB: null"); }
      try { WScript.Echo("Default: " + (objItem.Default.toArray()).join(",")); }
         catch(e) { WScript.Echo("Default: null"); }
      WScript.Echo("Description: " + objItem.Description);
      WScript.Echo("DeviceID: " + objItem.DeviceID);
      WScript.Echo("DeviceLoader: " + objItem.DeviceLoader);
      WScript.Echo("DeviceType: " + objItem.DeviceType);
      WScript.Echo("DialType: " + objItem.DialType);
      WScript.Echo("DriverDate: " + WMIDateStringToDate(objItem.DriverDate));
      WScript.Echo("ErrorCleared: " + objItem.ErrorCleared);
      WScript.Echo("ErrorControlForced: " + objItem.ErrorControlForced);
      WScript.Echo("ErrorControlInfo: " + objItem.ErrorControlInfo);
      WScript.Echo("ErrorControlOff: " + objItem.ErrorControlOff);
      WScript.Echo("ErrorControlOn: " + objItem.ErrorControlOn);
      WScript.Echo("ErrorDescription: " + objItem.ErrorDescription);
      WScript.Echo("FlowControlHard: " + objItem.FlowControlHard);
      WScript.Echo("FlowControlOff: " + objItem.FlowControlOff);
      WScript.Echo("FlowControlSoft: " + objItem.FlowControlSoft);
      WScript.Echo("InactivityScale: " + objItem.InactivityScale);
      WScript.Echo("InactivityTimeout: " + objItem.InactivityTimeout);
      WScript.Echo("Index: " + objItem.Index);
      WScript.Echo("InstallDate: " + WMIDateStringToDate(objItem.InstallDate));
      WScript.Echo("LastErrorCode: " + objItem.LastErrorCode);
      WScript.Echo("MaxBaudRateToPhone: " + objItem.MaxBaudRateToPhone);
      WScript.Echo("MaxBaudRateToSerialPort: " + objItem.MaxBaudRateToSerialPort);
      WScript.Echo("MaxNumberOfPasswords: " + objItem.MaxNumberOfPasswords);
      WScript.Echo("Model: " + objItem.Model);
      WScript.Echo("ModemInfPath: " + objItem.ModemInfPath);
      WScript.Echo("ModemInfSection: " + objItem.ModemInfSection);
      WScript.Echo("ModulationBell: " + objItem.ModulationBell);
      WScript.Echo("ModulationCCITT: " + objItem.ModulationCCITT);
      WScript.Echo("ModulationScheme: " + objItem.ModulationScheme);
      WScript.Echo("Name: " + objItem.Name);
      WScript.Echo("PNPDeviceID: " + objItem.PNPDeviceID);
      WScript.Echo("PortSubClass: " + objItem.PortSubClass);
      try { WScript.Echo("PowerManagementCapabilities: " + (objItem.PowerManagementCapabilities.toArray()).join(",")); }
         catch(e) { WScript.Echo("PowerManagementCapabilities: null"); }
      WScript.Echo("PowerManagementSupported: " + objItem.PowerManagementSupported);
      WScript.Echo("Prefix: " + objItem.Prefix);
      try { WScript.Echo("Properties: " + (objItem.Properties.toArray()).join(",")); }
         catch(e) { WScript.Echo("Properties: null"); }
      WScript.Echo("ProviderName: " + objItem.ProviderName);
      WScript.Echo("Pulse: " + objItem.Pulse);
      WScript.Echo("Reset: " + objItem.Reset);
      WScript.Echo("ResponsesKeyName: " + objItem.ResponsesKeyName);
      WScript.Echo("RingsBeforeAnswer: " + objItem.RingsBeforeAnswer);
      WScript.Echo("SpeakerModeDial: " + objItem.SpeakerModeDial);
      WScript.Echo("SpeakerModeOff: " + objItem.SpeakerModeOff);
      WScript.Echo("SpeakerModeOn: " + objItem.SpeakerModeOn);
      WScript.Echo("SpeakerModeSetup: " + objItem.SpeakerModeSetup);
      WScript.Echo("SpeakerVolumeHigh: " + objItem.SpeakerVolumeHigh);
      WScript.Echo("SpeakerVolumeInfo: " + objItem.SpeakerVolumeInfo);
      WScript.Echo("SpeakerVolumeLow: " + objItem.SpeakerVolumeLow);
      WScript.Echo("SpeakerVolumeMed: " + objItem.SpeakerVolumeMed);
      WScript.Echo("Status: " + objItem.Status);
      WScript.Echo("StatusInfo: " + objItem.StatusInfo);
      WScript.Echo("StringFormat: " + objItem.StringFormat);
      WScript.Echo("SupportsCallback: " + objItem.SupportsCallback);
      WScript.Echo("SupportsSynchronousConnect: " + objItem.SupportsSynchronousConnect);
      WScript.Echo("SystemCreationClassName: " + objItem.SystemCreationClassName);
      WScript.Echo("SystemName: " + objItem.SystemName);
      WScript.Echo("Terminator: " + objItem.Terminator);
      WScript.Echo("TimeOfLastReset: " + WMIDateStringToDate(objItem.TimeOfLastReset));
      WScript.Echo("Tone: " + objItem.Tone);
      WScript.Echo("VoiceSwitchFeature: " + objItem.VoiceSwitchFeature);
   }
}

function WMIDateStringToDate(dtmDate)
{
   if (dtmDate == null)
   {
      return "null date";
   }
   var strDateTime;
   if (dtmDate.substr(4, 1) == 0)
   {
      strDateTime = dtmDate.substr(5, 1) + "/";
   }
   else
   {
      strDateTime = dtmDate.substr(4, 2) + "/";
   }
   if (dtmDate.substr(6, 1) == 0)
   {
      strDateTime = strDateTime + dtmDate.substr(7, 1) + "/";
   }
   else
   {
      strDateTime = strDateTime + dtmDate.substr(6, 2) + "/";
   }
   strDateTime = strDateTime + dtmDate.substr(0, 4) + " " +
   dtmDate.substr(8, 2) + ":" +
   dtmDate.substr(10, 2) + ":" +
   dtmDate.substr(12, 2);
   return(strDateTime);
}