$x = Open(1, ".\PrinterOut.txt", 5)
$x = Open(2, ".\PrinterList.dat", 2)
$x = WriteLine(1, "The following printers are getting low on toner, please visit and assist:" + @CRLF + @CRLF)
Dim $StoreVals[6]
$EmailNeeded = 0
$PrinterIP = ReadLine(2)
While @ERROR = 0
$Cmd = 'snmpget.exe -r:' + $PrinterIP + ' -o:.1.3.6.1.2.1.1.1.0 -q -t:10'
$CmdResult = WshPipe($Cmd)
$CmdResult = Join($CmdResult[0], @CRLF)
$PModel = SubStr($CmdResult, Instr($CmdResult, "X"), (Instr($CmdResult, ";") - Instr($CmdResult, "X")))
$Count = 0
$Flag = 0
; If the device is online and the device is a Xerox machine
If Left($CmdResult, 1) <> "%" AND $PModel <> ""
; Get the supported values for a printer type
$aIniVals = Split(ReadProfileString('.\PrinterData.ini', $PModel, ''), Chr(10))
; Make sure the device is one of those listed in the INI file otherwise report an error
If UBound($aIniVals) > 0
For Each $IniVal in $aIniVals
If $IniVal
$Oid = ReadProfileString('.\PrinterData.ini', $PModel, $IniVal)
$Cmd = 'snmpget.exe -r:' + $PrinterIP + ' -o:' + $Oid + ' -q -t:10'
$CmdResult = WshPipe($Cmd)
$CmdResult = Join($CmdResult[0], @CRLF)
If $IniVal <> "Location"
$Cmd = 'snmpget.exe -r:' + $PrinterIP + ' -o:' + SUBSTR($Oid, 1, 23) + "8" + SUBSTR($Oid, 25, 4) + ' -q -t:10'
$CmdResult2 = WshPipe($Cmd)
$CmdResult2 = Join($CmdResult2[0], @CRLF)
$CmdResult = CDbl($CmdResult)
$CmdResult2 = CDbl($CmdResult2)
$StoreVals[$Count] = ($CmdResult / $CmdResult2) * 100
Else
$StoreVals[$Count] = $CmdResult
EndIf
EndIf
$Count = $Count + 1
Next
Else
$Count = 1
$StoreVals[$Count] = "WARNING - Printer Model Not Found : Report this to 3rd line"
EndIf
$PrinterText = $PrinterIP + " : " + $PModel
If $Count > 1
$PrinterText = $PrinterText + " : " + SubStr($StoreVals[0], 1, Len($StoreVals[0]) - 2)
For $x = 1 to ($Count - 2)
If $StoreVals[$x] <= 5
$PrinterText = $PrinterText + " : " + $aIniVals[$x] + " : " + $StoreVals[$x] + "%"
$Flag = 1
$EmailNeeded = 1
EndIf
Next
EndIf
If $Count = 1
$PrinterText = $PrinterText + $PrinterIP + " : " + $StoreVals[$Count]
$Flag = 1
$EmailNeeded = 1
EndIf
EndIf
If $Count = 0
$PrinterText = $PrinterIP + " : Device is offline (or not a Xerox device, check IP)"
$Flag = 1
$EmailNeeded = 1
EndIf
If $Flag
$x = WriteLine(1, $PrinterText + @CRLF)
EndIf
$PrinterIP = ReadLine(2)
LOOP
$x = Close(2)
$x = Close(1)
If $EmailNeeded
Shell "CMD.EXE /C C:\Scripts\blat.exe PrinterOut.txt -to blahblah@@company.com -subject " + Chr(34) + "Printers Low In Toner" + Chr(34) + " -q"
EndIf
Exit