Search the Community
Showing results for tags 'smart'.
-
;RemoteDriveInfo ;v0.0.0.1 ;Ressource ;Smart Temp : https://www.autoitscript.com/forum/topic/91067-drive-temperature/?do=findComment&comment=1091961 ;GetPNPDeviceID From DriveLetter : https://www.autoitscript.com/forum/topic/57202-need-help-get-pnp-device-id-for-usb-drive/?do=findComment&comment=433346 ;Get Disk Space Info : https://www.autoitscript.com/forum/topic/148390-wmi-query-how-to-get-data-from-object/?do=findComment&comment=1055088 ;For A to Z : https://www.autoitscript.com/forum/topic/4804-fornext-loop-with-letters/?do=findComment&comment=30417 ;Include #include <Array.au3> #include <String.au3> ;Sample 1 ;$sComputerName $sComputerName = "PC1" ;$sComputerName = "PC2" ;$sComputerName = @ComputerName ;$sDrive ;$sDrive = "system" ;$sDrive = "D:" $sDrive = "" $DriveInfo = _GetDriveInfo($sComputerName, $sDrive) _ArrayDisplay($DriveInfo) ;Sample 2 $DriveInfo = _GetDriveInfo($sComputerName, "system") If $DriveInfo[0][0] = "DriveLeter" Then If $DriveInfo[1][6] <> "" Then MsgBox(0, "", $DriveInfo[1][6] & "° - " & $DriveInfo[1][4] & "% ( " & Round($DriveInfo[1][2]/1024^3) & "Go / " & Round($DriveInfo[1][3]/1024^3) & "Go )" & @CRLF) Else MsgBox(0, "", $DriveInfo[1][4] & "% ( " & Round($DriveInfo[1][2]/1024^3) & "Go / " & Round($DriveInfo[1][3]/1024^3) & "Go )" & @CRLF) EndIf Else MsgBox(0, "", $DriveInfo[0][0] & @CRLF) EndIf ;Function Func _GetSystemDriveLtr($sComputerName) $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & "\root\cimv2") $colTemp = $objWMI.ExecQuery("SELECT SystemDrive FROM Win32_OperatingSystem") If IsObj($colTemp) then For $objItem In $colTemp $sSystemDriveLtr = $objItem.systemdrive Next EndIf Return $sSystemDriveLtr EndFunc ;==> _GetSystemDriveLtr Func _GetPNPDeviceID($drive_letter, $sComputerName) Local $drive_letter_found, $drive_letter_found $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $sComputerName & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDiskToPartition", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $LogicalDiskToPartitionAntecedent = _StringBetween($objItem.Antecedent, '"', '"') $LogicalDiskToPartitionDependent = _StringBetween($objItem.Dependent, '"', '"') ;ConsoleWrite(@CR & $LogicalDiskToPartitionAntecedent[0] & " - " & $LogicalDiskToPartitionDependent[0]) $drive_statistics = $LogicalDiskToPartitionAntecedent[0] $drive_letter_found = $LogicalDiskToPartitionDependent[0] If $drive_letter = $drive_letter_found Then ExitLoop EndIf Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_LogicalDiskToPartition") EndIf If $drive_letter <> $drive_letter_found Then Return 0 ; If drive letter isn't function returns 0 $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDriveToDiskPartition", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $DiskDriveToDiskPartitionAntecedent = _StringBetween($objItem.Antecedent, '"', '"') $DiskDriveToDiskPartitionDependent = _StringBetween($objItem.Dependent, '"', '"') ;ConsoleWrite(@CR & $DiskDriveToDiskPartitionAntecedent[0] & " - " & $DiskDriveToDiskPartitionDependent[0]) $drive_statistics_found = $DiskDriveToDiskPartitionDependent[0] $drive_physical = StringTrimLeft($DiskDriveToDiskPartitionAntecedent[0], StringInStr($DiskDriveToDiskPartitionAntecedent[0], "\", 1, -1)) ;MsgBox(0,"TEST", $drive_physical) If $drive_statistics = $drive_statistics_found Then ExitLoop EndIf Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DiskDriveToDiskPartition") EndIf $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems ;MsgBox(0,324234, $objItem.DeviceID) $DeviceID = StringTrimLeft($objItem.DeviceID, StringInStr($objItem.DeviceID, "\", 1, -1)) $PNPDeviceID = $objItem.PNPDeviceID ;MsgBox(0,122, $DeviceID) If $drive_physical = $DeviceID Then Return $PNPDeviceID EndIf Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DiskDrive") EndIf EndFunc ;==> _GetPNPDeviceID Func _GetSmartTemp($InstanceName, $sComputerName) $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & "\root\WMI") $colTemp = $objWMI.ExecQuery("SELECT * FROM MSStorageDriver_ATAPISmartData") $s = "" If IsObj($colTemp) and $InstanceName <> "" then For $objItem In $colTemp If StringInStr(StringUpper($objItem.InstanceName), StringUpper($InstanceName)) <> 0 Then $strVendorSpecific = $objItem.VendorSpecific For $i = 2 To UBound($strVendorSpecific) - 1 Step 12 If $strVendorSpecific[$i] = 0xC2 Then; find Vendor Parameter #194 - Temperatur $s &= " " & $strVendorSpecific[$i + 5]; Raw/Value celsuis ContinueLoop 2 EndIf Next For $i = 2 To UBound($strVendorSpecific) - 1 Step 12 If $strVendorSpecific[$i] = 0xBE Then; find Vendor Parameter #190 - Airflow Temperatur (if no tempetature is found) $s &= " " & $strVendorSpecific[$i + 5]; Raw/Value celsuis ContinueLoop 2 EndIf Next EndIf Next $s = StringTrimLeft($s, 1) Else $s = "" EndIf Return $s EndFunc ;==> _GetSmartTemp ;MainFunction Func _GetDriveInfo($sComputerName, $sDrive = "") Local $DriveArray[1][7] = [["DriveLeter", "FreespaceByte", "UsedspaceByte", "SizeByte", "UsedPercent", "IsSystem", "Temp"]] If Ping($sComputerName) = 0 Then Local $DriveArray[1][1] $DriveArray[0][0] = $sComputerName & " seems not online" Return $DriveArray EndIf If $sDrive = "" Then For $i = 65 To 90;For A to Z $sDriveLtr = Chr($i)&":" $DriveArray = _GetOneDriveInfo($sComputerName, $sDriveLtr, $DriveArray) Next ElseIf $sDrive = "system" Then $DriveArray = _GetOneDriveInfo($sComputerName, _GetSystemDriveLtr($sComputerName), $DriveArray) Else $DriveArray = _GetOneDriveInfo($sComputerName, $sDrive, $DriveArray) EndIf Return $DriveArray EndFunc ;==> _GetDriveInfo Func _GetOneDriveInfo($sComputerName, $sDriveLtr, $DriveArray) $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & '\root\cimv2:Win32_LogicalDisk="' & $sDriveLtr & '"') If IsObj($objWMI) Then $UsedPercent = Round(100 / $objWMI.Size * ($objWMI.Size - $objWMI.FreeSpace)) If $UsedPercent <> -9223372036854775807 then $current_line = Ubound($DriveArray)+1 ReDim $DriveArray[$current_line][7] $DriveArray[$current_line-1][0] = $sDriveLtr $FreespaceByte = $objWMI.FreeSpace $DriveArray[$current_line-1][1] = $FreespaceByte $SizeByte = $objWMI.Size $DriveArray[$current_line-1][3] = $SizeByte $UsedspaceByte = $objWMI.Size - $objWMI.FreeSpace $DriveArray[$current_line-1][2] = $UsedspaceByte $UsedPercent = Round(100 / $objWMI.Size * ($objWMI.Size - $objWMI.FreeSpace)) $DriveArray[$current_line-1][4] = $UsedPercent If _GetSystemDriveLtr($sComputerName) = $sDriveLtr Then $IsSystem = 1 Else $IsSystem = 0 EndIf $DriveArray[$current_line-1][5] = $IsSystem $InstanceName = _GetPNPDeviceID($sDriveLtr, $sComputerName) $Temp = _GetSmartTemp($InstanceName, $sComputerName) $DriveArray[$current_line-1][6] = $Temp EndIf EndIf Return $DriveArray EndFunc Ressource Smart Temp : GetPNPDeviceID From DriveLetter : Get Disk Space Info : For A to Z :