WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Last time ScanDisk and Defrag performed

 Keywords:  Last time ScanDisk and Defrag performed 

Question:

Does anyone know of a way to check when the last time a user has performed a scandisk and defrag on his hard drive via a winbatch script? There is a LastCheck key in the registry that tracks this information but it appears to be in hexadecimal form. How would that correspond to a normal system date form? Any help would be greatly appreciated.

The keys that I am referring to are

HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\LastCheck and
HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\LastOptimize.
I believe that the info there refers to the information that you would see when you looked at the properties of a drive and viewed the tools tab in the Win95 environment for the last time a scandisk and defrag was performed. How the info in those keys corresponds to system dates is where I am hitting the roadblock. Any ideas? Thanks in advance.

Answer:

Maybe this will do it...
;LastOptimize
AddExtender("wilx34i.dll")
ret= RegqueryBin(@RegMachine,"SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\LastOptimize[C]")
;D0 07 0A 00 05 00 06 00 0A 00 2B 00 27 00 2A 03
year = xHex(itemextract(2,ret," "))*256 + xHex(Itemextract(1,ret," "))
month = xHex(itemextract(3,ret," "))
days = xHex(itemextract(5,ret," "))
hour = xHex(itemextract(7,ret," "))
mins = xHex(itemextract(9,ret," "))
secs = xHex(itemextract(11,ret," "))
year = strfixleft(year,0,4)
month = strfixleft(month,0,2)
days = strfixleft(days,0,2)
hour = strfixleft(hour,0,2)
mins = strfixleft(mins,0,2)
secs = strfixleft(secs,0,2)
date = strcat(year,":",month ,":",days,":",hour ,":",mins ,":",secs)
message("LastOptimize date",date)


;LastCheck
;AddExtender("wilx34i.dll")
ret= RegqueryBin(@RegMachine,"SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\LastCheck[C]")
;D0 07 0A 00 05 00 06 00 09 00 22 00 14 00 76 02
year = xHex(itemextract(2,ret," "))*256 + xHex(Itemextract(1,ret," "))
month = xHex(itemextract(3,ret," "))
days = xHex(itemextract(5,ret," "))
hour = xHex(itemextract(7,ret," "))
mins = xHex(itemextract(9,ret," "))
secs = xHex(itemextract(11,ret," "))
year = strfixleft(year,0,4)
month = strfixleft(month,0,2)
days = strfixleft(days,0,2)
hour = strfixleft(hour,0,2)
mins = strfixleft(mins,0,2)
secs = strfixleft(secs,0,2)
date = strcat(year,":",month ,":",days,":",hour ,":",mins ,":",secs)
message("LastCheck date",date)
exit


Heres an example that uses a UDF in lieu of the loading the WILX Extender

#DefineFunction Dec2Hex(Dec)
   IsZero=@TRUE
   str="0123456789ABCDEF"
   hex=""
   
   for x=7 to 0 by -1
       nibble= (dec >> (x*4)) & 15
       if nibble==0 && IsZero==@TRUE then continue
       IsZero=@FALSE
       hex=strcat(hex,Strsub(str,nibble+1,1))
   next
   return(hex)
#EndFunction

;LastOptimize
ret= RegqueryBin(@RegMachine,"SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\LastOptimize[C]")
;D0 07 0A 00 05 00 06 00 0A 00 2B 00 27 00 2A 03
year = Dec2Hex(itemextract(2,ret," "))*256 + Dec2Hex(Itemextract(1,ret," "))
month = Dec2Hex(itemextract(3,ret," "))
days = Dec2Hex(itemextract(5,ret," "))
hour = Dec2Hex(itemextract(7,ret," "))
mins = Dec2Hex(itemextract(9,ret," "))
secs = Dec2Hex(itemextract(11,ret," "))
year = strfixleft(year,0,4)
month = strfixleft(month,0,2)
days = strfixleft(days,0,2)
hour = strfixleft(hour,0,2)
mins = strfixleft(mins,0,2)
secs = strfixleft(secs,0,2)
date = strcat(year,":",month ,":",days,":",hour ,":",mins ,":",secs)
message("LastOptimize date",date)

;LastCheck
ret= RegqueryBin(@RegMachine,"SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\LastCheck[C]")
;D0 07 0A 00 05 00 06 00 09 00 22 00 14 00 76 02
year = Dec2Hex(itemextract(2,ret," "))*256 + Dec2Hex(Itemextract(1,ret," "))
month = Dec2Hex(itemextract(3,ret," "))
days = Dec2Hex(itemextract(5,ret," "))
hour = Dec2Hex(itemextract(7,ret," "))
mins = Dec2Hex(itemextract(9,ret," "))
secs = Dec2Hex(itemextract(11,ret," "))
year = strfixleft(year,0,4)
month = strfixleft(month,0,2)
days = strfixleft(days,0,2)
hour = strfixleft(hour,0,2)
mins = strfixleft(mins,0,2)
secs = strfixleft(secs,0,2)
date = strcat(year,":",month ,":",days,":",hour ,":",mins ,":",secs)
message("LastCheck date",date)
exit



Article ID:   W14605
Filename:   Last time ScanDisk and Defrag performed.txt
File Created: 2001:03:08:16:16:18
Last Updated: 2001:03:08:16:16:18