Dellのバッテリーが交換対象か調べるスクリプト

Shigeya Tanabe's blog : PowerShell でバッテリーのモデルを調べる という記事を見て、WSH で同じようなやつを書いてみました。該当バッテリーのリストはWSH内に埋め込んでありますので、Dellのリストが更新されたときには、適宜書き換えてください。

Option Explicit
On Error Resume Next
Dim strAffected
Dim WMI
Dim strMachine
Dim objItems
Dim objRegExp
Dim strBatteryName

'https://www.dellbatteryprogram.com/

strAffected = _
  " 1K055 C5446 F2100 KD494 W5915 Y1333 " & _
  " 3K590 C6269 F5132 OR331 X5308 Y4500 " & _
  " 5P474 C6270 GD785 M3006 X5329 Y5466 " & _
  " 6P922 D2961 H3191 RD857 X5332 " & _
  " C2603 D5555 J1524 TD349 X5333 " & _
  " C5339 D6024 JD616 U5867 X5875 " & _
  " C5340 D6025 JD617 U5882 X5877"

strMachine = "."

Set WMI = GetObject( "winmgmts:\\" & strMachine & "\root\cimv2" )
Set objItems = WMI.ExecQuery( "SELECT * FROM Win32_Battery", , 48 )

Set objRegExp = New RegExp
objRegExp.Pattern = "^0*[A-Z0-9][A-Z0-9][0-9][0-9][0-9]$"
objRegExp.Global = True
objRegExp.IgnoreCase = False

For Each objBattery In objItems
    strBatteryName = objBattery.Name

    If objRegExp.Test( strBatteryName ) Then
        strBatteryName = Right( strBatteryName, 5 )
        If InStr( strAffected, strBatteryName ) > 0 Then
            WScript.Echo "Affected! " & objBattery.Name & " / " & _
                objBattery.Caption & " / " & objBattery.Description
        End If
    End If
Next

WScript.Quit