Что нового

Как получить данные из SMART HDD?

vovsla

Осваивающий
Сообщения
607
Репутация
36
Как можно с помощью автоита получить данные из SMART HDD? Очень интересует что-то универсальное, чтобы работало со всеми HDD.
 

kaster

Мой Аватар, он лучший самый
Команда форума
Глобальный модератор
Сообщения
4,020
Репутация
626
Попробуй вот это
http://autoit-script.ru/index.php?topic=2016.msg14743#msg14743
 
Автор
V

vovsla

Осваивающий
Сообщения
607
Репутация
36
это не подходит, там просто модель хдд, размер и т.п., а мне нужны данные из SMART, а именно сколько часов отработал хдд, хотя если будет возможность выдернуть все данные - это тоже пригодится
 

kaster

Мой Аватар, он лучший самый
Команда форума
Глобальный модератор
Сообщения
4,020
Репутация
626
Код:
#cs
   This AutoIt script file was generated by Project Express 4.0.6.9 Mar 09 / 2008
   AutoIt Compiler Version:         3.2.11.1
   Language:        English (US)
   Platform:        All
   Author:      George Gedye
   Company:         GEOSoft Software
   E-Mail:      geog AT mvps DOT org
  ;
   PX Project Name:         Smart Analysis
   Project Description:         S.M.A.R.T.  Drive Analysis GUI
   Remarks                              WMI analysis code by ptrex and ChrisL
#ce
Opt ("GUICoordMode","2")
Const $wbemFlagReturnImmediately = 0x10
Const $wbemFlagForwardOnly = 0x20
Dim $strComputer = "." 
Dim $objWMIService, $oMyError, $oDict, $oDictType
Dim $colItems, $strReserved, $strVendorSpecific, $strVendorSpecific4, $Output
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$fWarn = False
$Drives = DriveGetDrive("Fixed")
$Comb_Data = StringUpper(_ArrayToString($Drives,"|", 1))
Local $Col_w1 = 190, $Col_w2 = 70, $Col_w3 = 70, $Col_w4 = 60, $Col_w5 = 40, $Col_w6 = 40,$Col_w7 = 60
$Frm_Main = GUICreate("S.M.A.R.T. Drive Analysis", 570,410)
GUISetFont(10)
$Lbl_Dsel = GUICtrlCreateLabel("Select Drive", 10,10, 80, 20)
$Combo_Dsel = GUICtrlCreateCombo("", 0,-1, 60, 30)
$Lbl_Proc = GUICtrlCreateLabel("", 20, -1, 280, 20)
GUICtrlSetData($Combo_Dsel, $Comb_Data, StringUpper($Drives[1]))
GuiSetCoord(10, 45)
$Lbl_Attrib = GUICtrlCreateLabel("Attribute", -1,-1, $Col_w1,30, 1)
$Lbl_Type = GUICtrlCreateLabel("Type", 3, -1,$Col_w2,-1,1)
$Lbl_Flag = GUICtrlCreateLabel("Flag", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh = GUICtrlCreateLabel("Threshold", 3, -1, $Col_w4, -1,1)
$Lbl_Val = GUICtrlCreateLabel("Value", 3, -1, $Col_w5, -1,1)
$Lbl_Worst = GUICtrlCreateLabel("Worst", 3, -1, $Col_w6, -1,1)
$Lbl_Stat = GUICtrlCreateLabel("Status", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10,65)
$Lbl_Attrib1 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type1 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag1 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh1 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val1 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst1 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat1 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GUISetCoord(10,85)
$Lbl_Attrib2 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type2 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag2 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh2 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val2 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst2 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat2 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10,105)
$Lbl_Attrib3 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type3 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag3 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh3 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val3 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst3 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat3 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 125)
$Lbl_Attrib4 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type4 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag4 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh4 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val4 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst4 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat4 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 145)
$Lbl_Attrib5 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type5 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag5 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh5 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val5 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst5 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat5 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 165)
$Lbl_Attrib6 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type6 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag6 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh6 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val6 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst6 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat6 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 185)
$Lbl_Attrib7 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type7 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag7 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh7 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val7 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst7 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat7 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 205)
$Lbl_Attrib8 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type8 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag8 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh8 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val8 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst8 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat8 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 225)
$Lbl_Attrib9 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type9 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag9 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh9 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val9 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst9 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat9 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 245)
$Lbl_Attrib10 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type10 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag10 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh10 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val10 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst10 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat10 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 265)
$Lbl_Attrib11 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type11 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag11 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh11 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val11 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst11 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat11 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 285)
$Lbl_Attrib12 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type12 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag12 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh12 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val12 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst12 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat12 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 305)
$Lbl_Attrib13 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type13 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag13 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh13 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val13 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst13 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat13 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 325)
$Lbl_Attrib14 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type14 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag14 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh14 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val14 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst14 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat14 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(10, 345)
$Lbl_Attrib15 = GUICtrlCreateLabel("", -1,-1, $Col_w1,20)
$Lbl_Type15 = GUICtrlCreateLabel("", 3, -1,$Col_w2,-1,1)
$Lbl_Flag15 = GUICtrlCreateLabel("", 3, -1, $Col_w3, -1,1)
$Lbl_Thresh15 = GUICtrlCreateLabel("", 3, -1, $Col_w4, -1,1)
$Lbl_Val15 = GUICtrlCreateLabel("", 3, -1, $Col_w5, -1,1)
$Lbl_Worst15 = GUICtrlCreateLabel("", 3, -1, $Col_w6, -1,1)
$Lbl_Stat15 = GUICtrlCreateLabel("", 3, -1, $Col_w7, -1,1)
GuiSetCoord(240, 370)
$Btn_Chk = GUICtrlCreateButton("Check Drive", -1, -1, 80, 30)
$Lbl_Warn = GUICtrlCreateLabel( "", 40, -1, 120, 30, 1)
GUICtrlSetFont($Lbl_Warn, 14, 600)
GUICtrlSetColor($Lbl_Warn, 0xFF0000)
For $I = $Lbl_Attrib To $Lbl_Stat
   GUICtrlSetBkColor($I,0x00FFFF)
Next
For $I = $Lbl_Attrib1 To $Lbl_Stat15
   GUICtrlSetBkColor($I, 0xBFFFB1)
Next
GUISetState()
While 1
   $Msg = GUIGetMsg()
   Switch $Msg
      Case -3
         Exit
      Case $Btn_Chk
         $Drive = GUICtrlRead($Combo_Dsel)
         GUICtrlSetState($Btn_Chk, 144)
         For $I = $Lbl_Attrib1 To $Lbl_Stat15
            GUICtrlSetBkColor($I, 0xBFFFB1)
            GUICtrlSetData($I, "")
            GUICtrlSetColor($I, 0x000000)
         Next
         GUICtrlSetData($Lbl_Warn, "")
         GUICtrlSetData($Lbl_Proc, "Checking S.M.A.R.T. Data For Drive...  " & $Drive & "\")
         
         $SmartData = _GetSmartData($Drive)
         
         GUICtrlSetData($Lbl_Proc,"")
         If $SmartData <> -1 then 
            $sLbl = $Lbl_Attrib1
            For $I = 1 To Ubound($SmartData) -1
               For $J = 1 To 7
                  GUICtrlSetData($sLbl, $SmartData[$I][$J])
                  If $J = 7 AND $SmartData[$I][$J] = "NOT OK" Then
                     $rColor = 0xFAFCA0
                     $fColor = 0x000000
                     If $SmartData[$I][$J -5] = "Pre-Failure" Then
                        $rColor = 0xFFABFF
                        $fColor = 0xFF0000
                        $fWarn = True
                     EndIf
                     For $L = $sLbl -6 To $sLbl
                        GUICtrlSetBkColor($L, $rColor)
                        GUICtrlSetColor($L, $fColor)
                     Next
                  EndIf
                  $sLbl += 1
               Next
            Next
         Else
            Msgbox(0,"",'Unable to check "' & $drive & @CRLF & "The drive may not be S.M.A.R.T. capable")
         EndIf
         GUICtrlSetState($Btn_Chk, 80)
         If $fWarn Then GUICtrlSetData($Lbl_Warn, "WARNING !")
   EndSwitch
Wend


Func _GetSmartData($vDrive  = "C:")
   If DriveStatus ( $vDrive ) <> "Ready" then 
      SetError(1)
      Return -1
   EndIf
   
   If StringLeft($vDrive,1) <> '"' then $vDrive = '"' & $vDrive
   If StringRight($vDrive,1) <> '"' then $vDrive &= '"'
   
   Local $iCnt, $iCheck, $vPartition,$vDeviceID,$vPNPID
   
   $vPartition = _LogicalToPartition ($vDrive)
   If $vPartition = -1 then Return -1
   
   $vDeviceID = _PartitionToPhysicalDriveID($vPartition)
   If $vDeviceID = -1 then Return -1
   
   $vPNPID = _PNPIDFromPhysicalDriveID($vDeviceID)
   If $vPNPID = -1 then Return -1
   
   $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\WMI")
   $oDict = ObjCreate("Scripting.Dictionary")
   
   $colItems1 = $objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_ATAPISmartData", "WQL", _
         $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
   
   $colItems2 = $objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_FailurePredictThresholds", "WQL", _
         $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
   
   $colItems3 = $objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_FailurePredictStatus", "WQL", _
         $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
   
   _CreateDict(); Create Dictionary
   ConsoleWrite ($strComputer&@CR)                            
   
   $iCnt = 1
   For $objItem In $colItems1
      If StringLeft($objItem.InstanceName,StringLen($vPNPID)) = String($vPNPID) AND StringLeft($objItem.InstanceName, 3) = "ide" then 
         ConsoleWrite ("Active: " & $objItem.Active&@CR)
         ConsoleWrite ("Checksum: " & $objItem.Checksum&@CR)
         ConsoleWrite ("ErrorLogCapability: " & $objItem.ErrorLogCapability&@CR)
         ConsoleWrite ("ExtendedPollTimeInMinutes: " & $objItem.ExtendedPollTimeInMinutes&@CR)
         ConsoleWrite ("InstanceName: " & $objItem.InstanceName&@CR)
         ConsoleWrite ("Length: " & $objItem.Length&@CR)
         ConsoleWrite ("OfflineCollectCapability: " & $objItem.OfflineCollectCapability&@CR)
         ConsoleWrite ("OfflineCollectionStatus: " & $objItem.OfflineCollectionStatus&@CR)
         $strReserved = $objItem.Reserved
         ConsoleWrite ("Reserved: " & _ArrayToString($strReserved,",")&@CR)
         ConsoleWrite ("SelfTestStatus: " & $objItem.SelfTestStatus&@CR)
         ConsoleWrite ("ShortPollTimeInMinutes: " & $objItem.ShortPollTimeInMinutes&@CR)
         ConsoleWrite ("SmartCapability: " & $objItem.SmartCapability&@CR)
         ConsoleWrite ("TotalTime: " & $objItem.TotalTime&@CR)
         $strVendorSpecific = $objItem.VendorSpecific
         ConsoleWrite ("VendorSpecific: " & _ArrayToString($strVendorSpecific,",")&@CR)
         ConsoleWrite ("VendorSpecific2: " & $objItem.VendorSpecific2&@CR)
         ConsoleWrite ("VendorSpecific3: " & $objItem.VendorSpecific3&@CR)
         $strVendorSpecific4 = $objItem.VendorSpecific4
         ConsoleWrite ("VendorSpecific4: " & _ArrayToString($strVendorSpecific4,",")&@CR)
      Else
         
         $iCnt +=1
      EndIf
      
   Next
   
   
   $iCheck = 1
   For $objItem In $colItems2
      If $iCheck = $iCnt then 
         $strVendorSpecific2 = $objItem.VendorSpecific
         ConsoleWrite ("FailurePredictThresholds: " & _ArrayToString($strVendorSpecific2,",")&@CR)
      Else
         $iCheck +=1
      EndIf
   Next
   
   $iCheck = 1
   For $objItem In $colItems3
      If $iCheck = $iCnt then 
         $strVendorSpecific3 = $objItem.PredictFailure
         ConsoleWrite ("PredictFailure: " & $strVendorSpecific3&@CR)
         $strVendorSpecific3 = $objItem.Reason
         ConsoleWrite ("PredictReason: " & $strVendorSpecific4&@CR)
      Else
         $iCheck +=1
      EndIf
   Next
   
   If NOT IsArray($strVendorSpecific4) then Return -1;Not a Smart capable drive
   If NOT IsArray($strVendorSpecific2) then Return -1
   
   Dim $Status [22]
   For $i = 1 to 21
      $Status[$i] = "NOT OK";default all status to "NOT OK"
   Next
   
  ;if a status passes then Change it to OK
   If $strVendorSpecific[5] >= $strVendorSpecific2[3]  then $Status[1] = "OK"
   If $strVendorSpecific[17] >= $strVendorSpecific2[15] then $Status[2] = "OK"
   If $strVendorSpecific[29] >= $strVendorSpecific2[27] then $Status[3] = "OK"
   If $strVendorSpecific[41] >= $strVendorSpecific2[39] then $Status[4] = "OK"
   If $strVendorSpecific[53] >= $strVendorSpecific2[51] then $Status[5] = "OK"
   If $strVendorSpecific[65] >= $strVendorSpecific2[63] then $Status[6] = "OK"
   If $strVendorSpecific[77] >= $strVendorSpecific2[75] then $Status[7] = "OK"
   If $strVendorSpecific[89] >= $strVendorSpecific2[87] then $Status[8] = "OK"
   If $strVendorSpecific[101] >= $strVendorSpecific2[99] then $Status[9] = "OK"
   If $strVendorSpecific[113] >= $strVendorSpecific2[111] then $Status[10] = "OK"
   If $strVendorSpecific[125] >= $strVendorSpecific2[123] then $Status[11] = "OK"
   If $strVendorSpecific[137] >= $strVendorSpecific2[135] then $Status[12] = "OK"
   If $strVendorSpecific[149] >= $strVendorSpecific2[147] then $Status[13] = "OK"
   If $strVendorSpecific[161] >= $strVendorSpecific2[159] then $Status[14] = "OK"
   If $strVendorSpecific[173] >= $strVendorSpecific2[171] then $Status[15] = "OK"
   If $strVendorSpecific[185] >= $strVendorSpecific2[183] then $Status[16] = "OK"
   If $strVendorSpecific[197] >= $strVendorSpecific2[195] then $Status[17] = "OK"
   If $strVendorSpecific[206] >= $strVendorSpecific2[204] then $Status[18] = "OK"
   If $strVendorSpecific[218] >= $strVendorSpecific2[216] then $Status[19] = "OK"
   If $strVendorSpecific[230] >= $strVendorSpecific2[228] then $Status[20] = "OK"
   If $strVendorSpecific[242] >= $strVendorSpecific2[240] then $Status[21] = "OK"
   
   
   
   Dim $aSmartData[1][8] = [["ID","Attribute","Type","Flag","Threshold","Value","Worst","Status"]]
   $iCnt=1
   For $x = 2 to 242 Step 12 
      If $strVendorSpecific[$x] <> 0 then;0 id is not valid for this Smart Device
         $NextRow = Ubound($aSmartData)
         Redim $aSmartData[$NextRow +1][8]
         $aSmartData[$NextRow][0] = $strVendorSpecific[$x];ID
         $aSmartData[$NextRow][1] = $oDict.Item($strVendorSpecific[$x]);Attribute
         If $aSmartData[$NextRow][1] = "" then $aSmartData[$NextRow][1] = "Unknown Smart Attribute"
         
         If Mod($strVendorSpecific[$x +1],2) then;Type If odd number then it is a pre-failure value
         $aSmartData[$NextRow][2] = "Pre-Failure" 
      Else
         $aSmartData[$NextRow][2] = "Advisory" 
      EndIf
      $aSmartData[$NextRow][3] = "0x" & Hex($strVendorSpecific[$x +1], 4);Flag
      $aSmartData[$NextRow][4] = $strVendorSpecific2[$x +1];Threshold
      $aSmartData[$NextRow][5] = $strVendorSpecific[$x +3];Value
      $aSmartData[$NextRow][6] = $strVendorSpecific[$x +4];Worst
      $aSmartData[$NextRow][7] = $Status[$iCnt];Status
   EndIf
      $iCnt+=1
   Next

   Return   $aSmartData
EndFunc  ;<==> _GetSmartData($vDrive  = "C:")

Func _PartitionToPhysicalDriveID($vPart)
   
   $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
   $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDriveToDiskPartition", "WQL", _
         $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
   If IsObj($colItems) then
      For $objItem In $colItems
         If $objItem.Dependent == $vPart then 
            $vPdisk = $objItem.Antecedent
            $vPdisk = StringReplace(StringTrimLeft($vPdisk,Stringinstr($vPdisk,"=")),'"',"")
            $strDeviceID = StringReplace($vPdisk, "\\", "\")
            Return $strDeviceID
         Endif
      Next
   Endif
   Return -1
EndFunc  ;<==> _PartitionToPhysicalDriveID($vPart)

Func _PNPIDFromPhysicalDriveID($vDriveID)
   
   $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _
         $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
   If IsObj($colItems) then
      For $objItem In $colItems
         If $objItem.DeviceID == $vDriveID then
            Return $objItem.PNPDeviceID
         EndIf
      Next
   Endif
   Return -1
EndFunc  ;<==> _PNPIDFromPhysicalDriveID($vDriveID)

Func _LogicalToPartition ($vDriveLet)
   Local $objWMIService,$colItems,$vAntecedent,$vPartition
   
   $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
   $colItems = $objWMIService.ExecQuery("SELECT Dependent,Antecedent FROM Win32_LogicalDiskToPartition", "WQL", _
         $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
   If IsObj($colItems) then
      For $objItem In $colItems
         If StringRight($objItem.Dependent,4) == $vDriveLet then 
            $vAntecedent=$objItem.Antecedent
            $Output &= $vDriveLet & "  =  " & StringRight($objItem.Dependent,4) & @CRLF
            Return $vAntecedent;$partition
         EndIf
      Next
   Endif
   Return -1
EndFunc  ;<==> _LogicalToPartition ($vDriveLet)


Func _CreateDict()
   $oDict.Add(1,"Read Error Rate")
   $oDict.Add(2,"Throughput Performance")
   $oDict.Add(3,"Spin-Up Time")
   $oDict.Add(4,"Start/Stop Count")
   $oDict.Add(5,"Reallocated Sectors Count")
   $oDict.Add(6,"Read Channel Margin")
   $oDict.Add(7,"Seek Error Rate Rate")
   $oDict.Add(8,"Seek Time Performance")
   $oDict.Add(9,"Power-On Hours (POH)")
   $oDict.Add(10,"Spin Retry Count")
   $oDict.Add(11,"Recalibration Retries")
   $oDict.Add(12,"Device Power Cycle Count")
   $oDict.Add(13,"Soft Read Error Rate")
   $oDict.Add(191,"G-Sense Error Rate Frequency")
   $oDict.Add(192,"Power-Off Park Count")
   $oDict.Add(193,"Load/Unload Cycle")
   $oDict.Add(194,"HDA Temperature")
   $oDict.Add(195,"ECC Corrected Count")
   $oDict.Add(196,"Reallocated Event Count")
   $oDict.Add(197,"Current Pending Sector Count")
   $oDict.Add(198,"Uncorrectable Sector Count")
   $oDict.Add(199,"UltraDMA CRC Error Count")
   $oDict.Add(200,"Write Error Rate")
   $oDict.Add(201,"Soft Read Error Rate")
   $oDict.Add(202,"Address Mark Errors Frequency")
   $oDict.Add(203,"ECC errors (Maxtor: ECC Errors)")
   $oDict.Add(204, "Soft ECC Correction")
   $oDict.Add(205, "Thermal Asperity Rate (TAR)")
   $oDict.Add(206, "Flying Height")
   $oDict.Add(207, "Spin High Current")
   $oDict.Add(208, "Spin Buzz")
   $oDict.Add(209, "Offline Seek")
   $oDict.Add(220, "Disk Shift")
   $oDict.Add(221, "G-Sense Error Rate")
   $oDict.Add(222, "Loaded Hours")
   $oDict.Add(223, "Load/Unload Retry Count")
   $oDict.Add(224, "Load Friction")
   $oDict.Add(225, "/Unload Cycle Count")
   $oDict.Add(226, "Load 'In'-time")
   $oDict.Add(227, "Torque Amplification Count")
   $oDict.Add(228, "Power-Off Retract Cycle")
   $oDict.Add(230, "GMR Head Amplitude")
   $oDict.Add(231, "Temperature")
   $oDict.Add(240, "Head Flying Hours")
   $oDict.Add(250, "Read Error Retry Rate")
EndFunc  ;<==> _CreateDict()

Func _ArrayToString(Const ByRef $avArray, $sDelim = "|", $iStart = 0, $iEnd = 0)
    If Not IsArray($avArray) Then Return SetError(1, 0, "")

    Local $sResult, $iUBound = UBound($avArray) - 1

; Bounds checking
    If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound
    If $iStart < 0 Then $iStart = 0
    If $iStart > $iEnd Then Return SetError(2, 0, "")

; Combine
    For $i = $iStart To $iEnd
        $sResult &= $avArray[$i] & $sDelim
    Next

    Return StringTrimRight($sResult, StringLen($sDelim))
EndFunc  ;==>_ArrayToString


;This is COM error handler
Func MyErrFunc()
   $HexNumber=hex($oMyError.number,8)
   Return
   Msgbox(0,"COM Error Test","We intercepted a COM Error !"    & @CRLF  & @CRLF & _
         "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
         "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
         "err.number is: "       & @TAB & $HexNumber              & @CRLF & _
         "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
         "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
         "err.source is: "       & @TAB & $oMyError.source       & @CRLF & _
         "err.helpfile is: "       & @TAB & $oMyError.helpfile     & @CRLF & _
         "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
         )
   SetError(1) ; to check for after this function returns
Endfunc  ;<==> MyErrFunc()
 
Автор
V

vovsla

Осваивающий
Сообщения
607
Репутация
36
выдаёт:
Unable to check "C:
The drive may not be S.M.A.R.T. capable
 
Верх