Get Windows Experience Index base score for Vista
This snippet empowers the bearer the ability to check the base score of a machine capable of omitting one, e.g. Vista or higher. A base score is calculated regarding the computer's lowest rating per component tested (or subscore).
[VB.NET]
''' <summary>
''' Gets the base score of a computer running Windows Vista or higher.
''' </summary>
''' <returns>The String Representation of Score, or False.</returns>
''' <remarks></remarks>
Public Function GetBaseScore() As String
' Check if the computer has a \WinSAT dir.
If System.IO.Directory.Exists("C:\Windows\Performance\WinSAT\DataStore") Then
' Our method to get the most recently updated score.
' Because the program makes a new XML file on every update of the score,
' we need to calculate the most recent, just incase the owner has upgraded.
Dim Dir As New IO.DirectoryInfo("C:\Windows\Performance\WinSAT\DataStore")
Dim fileDir() As IO.FileInfo
Dim fileMostRecent As IO.FileInfo
Dim LastAccessTime As Date
Dim LastAccessPath As String = ""
fileDir = Dir.GetFiles
' Loop through the files in the \WinSAT dir to find the newest one.
For Each fileMostRecent In fileDir
If fileMostRecent.LastAccessTime >= LastAccessTime Then
LastAccessTime = fileMostRecent.LastAccessTime
LastAccessPath = fileMostRecent.FullName
End If
Next
' Create an XmlTextReader instance.
Dim xmlReadScore As New System.Xml.XmlTextReader(LastAccessPath)
' Disable whitespace handling so we don't read over them
xmlReadScore.WhitespaceHandling = System.Xml.WhitespaceHandling.None
' We need to get to the 25th tag, "WinSPR".
For I As Integer = 0 To 26
xmlReadScore.Read()
Next
' Create a string variable, so we can clean up without any mishaps.
Dim SystemScore As String = xmlReadScore.ReadElementString("SystemScore")
' Clean up.
xmlReadScore.Close()
Return SystemScore ' Return the String representation of the Base Score.
End If
' Unsuccessful.
Return False
End Function
See Also
- Dream In Code Submission - http://www.dreamincode.net/code/snippet1456.htm
page_revision: 0, last_edited: 1195463662|%e %b %Y, %H:%M %Z (%O ago)





