iCritical = 0 ' Количество критических ошибок iWarning = 0 ' Количество предупреждений iSuccess = 0 ' Количество успешных strCmd = CMD("""C:\Program Files\CA\ARCserve Backup\ca_qmgr.exe"" -list") Lines = Split(strCmd, vbCrLf) ' Парсим выход for each Line in Lines iPos = inStr(Line, "READY") if (iPos) then select case (Trim(Mid(Line, iPos + 42, 15))) case "FINISHED" iSuccess = iSuccess + 1 case "FAILED", "RUN FAILED", "CRASHED" iCritical = iCritical + 1 case "INCOMPLETE", "CANCELLED" iWarning = iWarning + 1 end select end if next Out = "" ' Генерим статусную строку-комментарий if (iCritical) then Out = "Critical: " & iCritical end if if (iWarning) then Out = Out & " Warning: " & iWarning end if if (iSuccess) then Out = Out & " Success: " & iSuccess end if if (iCritical = 0) and (iWarning = 0) and (iSuccess = 0) then Out = Out & " UNKNOWN results" end if ' Выводим статус WScript.StdOut.WriteLine (Out) ' Решаем общий статус if (iCritical) then WScript.Quit(2) elseif (iWarning) then WScript.Quit(1) elseif (iSuccess) then WScript.Quit(0) else WScript.Quit(3) end if ' Что-то пошло не так.... статус возврата - неизвестен (UNKNOWN) WScript.Quit(3) ' ---------------------------------------- Функции ------------------------------------------ ' Возвращает в строке - результат выполнения указанной команды. function CMD(byRef cmdLine) set oShell = WScript.CreateObject("WScript.Shell") set oExec = oShell.Exec(cmdLine) ret = oExec.StdOut.Readall() set oExec = nothing: Set oShell = nothing CMD = ret end function