Jump to content

Drive Temperature


James
 Share

Recommended Posts

I thought I'd share this with you as a "snippet" because it may just come in useful. I am currently using it for Disk Manager :P As far as I know, it works fine - fingers crossed.

Global $strComputer = "."
Global $objWMIService, $oMyError
Global $colTemp

$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\WMI")

$colTemp = $objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_ATAPISmartData")
For $objItem In $colTemp
$strVendorSpecific = $objItem.VendorSpecific
ConsoleWrite("Temperature: " & $strVendorSpecific[115] & @CRLF)
Next

Func MyErrFunc()
$HexNumber = Hex($oMyError.number, 8)
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
Edited by James
Link to comment
Share on other sites

@JamesBrooks

I've done some tests and found some arrays matching with my Drive temperature :

$strVendorSpecific[127]
$strVendorSpecific[130]
$strVendorSpecific[137]
$strVendorSpecific[139]

Cheers, FireFox.

Link to comment
Share on other sites

@JamesBrooks

Here is my little example :

Local $strComputer = '.', $objWMIService, $oMyError, $colTemp

$oMyError = ObjEvent('AutoIt.Error', 'MyErrFunc')
$objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\root\WMI')

Opt('GUIOnEventMode', 1)

#Region GUI
$GUI = GUICreate('Drive temperature', 120, 75)
GUISetOnEvent(-3, '_Exit')
$tmp = GUICtrlCreateLabel('0 °C', 0, 5, 120, 40, 1)
GUICtrlSetFont($tmp, 24)

GUICtrlCreateButton('Refresh', 35, 50, 50, 20)
GUICtrlSetOnEvent(-1, '_RefreshTemp')
GUISetState(@SW_SHOW, $GUI)
#EndRegion GUI
;

While 1
    Sleep(250)
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Func _RefreshTemp()
    GUICtrlSetData($tmp, _WMI_DriveTemperature() & ' °C')
    TraySetToolTip(_WMI_DriveTemperature() & ' °C')
EndFunc   ;==>_RefreshTemp

Func _WMI_DriveTemperature()
    $colTemp = $objWMIService.ExecQuery('SELECT * FROM MSStorageDriver_ATAPISmartData')
    For $objItem In $colTemp
        $strVendorSpecific = $objItem.VendorSpecific
        Return $strVendorSpecific[127]
    Next
EndFunc   ;==>_WMI_DriveTemperature


Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    MsgBox(64, '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

Cheers, FireFox.

Link to comment
Share on other sites

Your example shows 101 :P

I think this is a very vendor-specific thing. For my Maxtor and Hitachi drives, I was reading the temp at [149]. I used 'SpeedFan' to match them up. Unfortunately, readings seemed off for both SpeedFan and the results. Doing searches on smartvsd.vxd and SMART IOCTL API might help..

*I should note: 'vxd' drivers were for Win9x systems.. not sure what NT-based systems use for the interface

Edited by ascendant
Link to comment
Share on other sites

You said motherboard manufacturers.. I think instead Drive Temps are more of a hard-drive manufacturer thing, no?

Link to comment
Share on other sites

These values seem to be the one for my pc:

ConsoleWrite("Temperature: " & $strVendorSpecific[127] & @CRLF)

ConsoleWrite("Temperature: " & $strVendorSpecific[173] & @CRLF)

ConsoleWrite("Temperature: " & $strVendorSpecific[175] & @CRLF)

Temperature: 44
     Temperature: 44
     Temperature: 44

My WMI output:

Active: True
     Checksum: 250
     ErrorLogCapability: 1
     ExtendedPollTimeInMinutes: 111
     InstanceName: IDE\DiskST9120823AS_____________________________3.ADC___\5&1d98b533&0&0.0.0_0
     Length: 512
     OfflineCollectCapability: 83
     OfflineCollectionStatus: 0
     Reserved: 3,0,0,0,0,0,0,0,0,0,0,0
     SelfTestStatus: 38
     ShortPollTimeInMinutes: 2
     SmartCapability: 3
     TotalTime: 426
     VendorSpecific: 10,0,1,15,0,100,253,0,0,0,0,0,0,0,3,3,0,98,98,0,0,0,0,0,0,0,4,50,0,100,100,89,3,0,0,0,0,0,5,51,0,100


 
    ,100,0,0,0,0,0,0,0,7,15,0,81,60,138,198,225,8,0,0,0,9,50,0,97,97,161,10,0,0,0,0,0,10,19,0,100,1

00,0,
 
    0,0,0,0,0,0,12,50,0,100,100,103,3,0,0,0,0,0,187,50,0,100,100,0,0,0,0,0,0,0,189,58,0,100,100,0,0

,0,0,
 
    0,0,0,190,34,0,56,47,  44  ,0,19,49,0,0,0,191,50,0,100,100,0,0,0,0,0,0,0,192,50,0,100,100,28,2,0,0,0,0,0,193,34,0,68,68,15

4
    ,0,1,0,0,0,0,194,26,0,  44  ,53,  44  ,0,0,0,15,0,0,195,18,0,64,57,245,185,11,13,0,0,0,197,16,0,100,100,0,0,0,0,0,0,0,198,62,0,100,10

0
    ,0,0,0,0,0,0,0,199,0,0,200,200,0,0,0,0,0,0,0,200,50,0,100,253,0,0,0,0,0,0,0,202,0,0,100,253,0,0

,0,0,
 
    0,0,0,254,0,0,100,253,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

,0,0,
 
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

,0,0,
 
    0,0,0,0,0,0,0,0,0,0,0,0,0,0
     VendorSpecific2: 0
     VendorSpecific3: 105
     VendorSpecific4: 0,0,0,0,7,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,1,0,0,0,0,105,6,0,0,1,0,12,44,81,238,41,1,0,0,0,0,0,0,0,0,


 
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,1,0,0,0,0,0,0,0,37,148,136,228,1,0,0,0,194,141,44,2,0,0,0,0

,0,0,
 
    0,0,0,0,183,10,5,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...