Parse list of hard drive data for temperature

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
darioit
Posts: 230
Joined: 02 Aug 2010 05:25

Parse list of hard drive data for temperature

#1 Post by darioit » 03 Feb 2014 23:53

Hello I have this script for get hard disk temperature

Code: Select all

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\WMI")
Set colItems = objWMIService.ExecQuery( "SELECT * FROM MSStorageDriver_ATAPISmartData",,48)
For Each objItem in colItems
    If isNull(objItem.VendorSpecific) Then
        Wscript.Echo "VendorSpecific: "
    Else
        WScript.Echo "VendorSpecific: " & Join(objItem.VendorSpecific, ",")
    End If
Next


run with:
cscript //nologo temp.vbs

and the result is:

Code: Select all

VendorSpecific: 16,0,1,11,0,100,100,0,0,0,0,0,0,0,2,5,0,100,100,0,0,0,0,0,0,0,3,7,0,172,172,1,0,0,0,13,0,0,4,18,0,100,100,27,1,0,0,0,0,0,5,5
1,0,100,100,0,0,0,0,0,0,0,7,11,0,100,100,0,0,0,0,0,0,0,8,5,0,100,100,0,0,0,0,0,0,0,9,18,0,85,85,69,27,0,0,0,0,0,10,19,0,100,100,0,0,0,0,0,0,
0,12,50,0,100,100,144,0,0,0,0,0,0,191,10,0,100,100,0,0,0,0,0,0,0,192,50,0,100,100,68,0,0,0,0,0,0,193,18,0,97,97,81,149,0,0,0,0,0,194,2,0,127
,127,47,0,18,0,52,0,0,196,50,0,100,100,0,0,0,0,0,0,0,197,34,0,100,100,0,0,0,0,0,0,0,198,8,0,100,100,0,0,0,0,0,0,0,199,10,0,200,200,0,0,0,0,0
,0,0,223,10,0,100,100,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,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


How can I display only value 115 ? (47 degree)

Regards

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Pharse

#2 Post by foxidrive » 04 Feb 2014 01:15

Try this - you may need to adjust the 115 up or down by 1, I couldn't be certain it gets the right cell.

Code: Select all

@echo off
for /f "delims=" %%a in ('cscript /nologo "file.vbs" ') do call :next %%a
pause
GOTO:EOF
:next
for /L %%b in (1,1,115) do shift
echo.%1

darioit
Posts: 230
Joined: 02 Aug 2010 05:25

Re: Parse list of hard drive data for temperature

#3 Post by darioit » 04 Feb 2014 03:01

Thank you foxidrive, but how can I get same result using this raw

Code: Select all

WScript.Echo "VendorSpecific: " & Join(objItem.VendorSpecific, ",")


I would like to use:

Code: Select all

WScript.Echo "VendorSpecific: " & Join(objItem.VendorSpecific[115])


But doesn't work

Regards

Matt Williamson
Posts: 82
Joined: 30 Dec 2013 10:16
Location: United States by the big waterfall

Re: Parse list of hard drive data for temperature

#4 Post by Matt Williamson » 06 Feb 2014 08:41

This is a pure batch way of getting the HD temp. It works on my computer since I have a western digital hard drive. You may have to adjust for yours.

Code: Select all

::GetHardDriveTemp

@echo off
setlocal enabledelayedexpansion

set q=wmic /namespace:\\root\wmi path MSStorageDriver_ATAPISmartData get VendorSpecific
for /f "delims=" %%a in ('%q%^|find ","') do (
   set i=0
   for %%c in (%%a) do (
     set /a i+=1
     set "ary[!i!]=%%c"
    )
)
      
for /L %%a in (1,1,%i%) do (
   if !ary[%%a]! EQU 190 (
     set /a j=5+%%a
     for %%b in (!j!) do echo !ary[%%b]! Degrees C & goto :EOF
   ) 
)

Post Reply