The following simple VBS script designed to log the change of a specific self-monitoring (S.M.A.R.T.) attribute of IDE/SATA hard disk drives. By this script, it is possible to keep track the changes of an attribute, inspect how it changes with time. The result CSV file format can be loaded into Excel to examine or draw graph about the results.
In order to work, Hard Disk Sentinel Professional version should be installed. The software needs to be registered and activated and the option Configuration -> Advanced Options -> Provide status information by WMI option must be enabled.
To keep track the amount of load/unload cycles performed by the hard disk drive, use the following script:
Do strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\wmi") Set colItems = objWMIService.ExecQuery("Select * from HDSentinel",,48) For Each objItem in colItems If objItem.ID = "Drive 0" Then datetime = FormatDateTime(Now) drvid = objItem.ID & "," & objItem.ModelID & "," & objItem.SerialNumber powerontime = 0 smart = Split(objItem.SMART, chr(13)) For Each attr in smart info = Split(attr, ",") If (info(0) = "9") Then potime = CLng ("&H" & info(6)) End If If (info(0) = "193") Or (info(0) = "225") Then attrv = CLng ("&H" & info(6)) Wscript.Echo datetime &","& drvid &","& potime &","& info(0) &" "& info(1) &","& info(6) &","& attrv End If Next End If Next WScript.Sleep 60000 Loop Until False
You can download the script from the bottom of this page or it is possible to prepare this way:
1. Open a notepad and copy/paste the above code to and save the file as smartlog.vbs in an empty folder.
2. Open a notepad and copy/paste the following: cscript /nologo smartlog.vbs >loadunload.csv and save the file as smartlog.bat in the same folder.
3. Then launch smartlog.bat file.
Detailed instructions
The script uses the status information detected by Hard Disk Sentinel to automatically log the details of Drive 0. The script checks for attribute 193 or 255, as depending on the manufacturer/model, these attributes reflect the Load/unload cycle count.
For reference, the script also saves the current date/time, the drive number, the drive model ID and serial number, the power on time count and also the S.M.A.R.T. attribute number and name and the attribute value (the Load/unload cycle count in this example) in both hexadecimal and decimal format, so the last item in each line shows the current Load/unload cycle count value of the corresponding hard disk drive.
Sample output:
2025.03.10. 7:17:40,Drive 2,ST2000LM003 HN-M201RAD,S34RJ9EG108891,17081,225 Load/Unload Cycle Count,0000000070E6,28902 2025.03.10. 7:18:40,Drive 2,ST2000LM003 HN-M201RAD,S34RJ9EG108891,17081,225 Load/Unload Cycle Count,0000000070E6,28902 2025.03.10. 7:19:40,Drive 2,ST2000LM003 HN-M201RAD,S34RJ9EG108891,17082,225 Load/Unload Cycle Count,0000000070E6,28902 2025.03.10. 7:20:40,Drive 2,ST2000LM003 HN-M201RAD,S34RJ9EG108891,17082,225 Load/Unload Cycle Count,0000000070E6,28902
Notes
The script "asks" the status information from Hard Disk Sentinel Pro once per every minute (see the 60000 at the end: this is a delay in milliseconds unit between two detection cycles. However, in order to receive frequent detected information, you may need to adjust the detection frequency in Hard Disk Sentinel Pro (see Configuration -> Advanced options page), otherwise you may see status updates only once per every 5 minute only.
The script runs until terminated by CTRL+C or closing the appropriate window. Without closing, it can be used to log status/details for very long time.
By changing the proper lines, it is possible to create different log scripts for different drives and/or for other attributes too:
just replace the drive number in the line of If objItem.ID = "Drive 0" Then to different value to specify different hard disk drive
just replace the line of If (info(0) = "193") Or (info(0) = "225") Then to if (info(0) = "4") Then to log the change of the
Start/Stop count attribute.
Or you may replace to if (info(0) = "194") Then to log the change of the Disk Temperature S.M.A.R.T. attribute
You can right click and save the above mentioned files directly: