Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve Windows Experience Rating

Tags:

c#

rating

I'm looking to retrieve a machine's windows experience rating in C#. If possible I would also like to retrieve the numbers for each component (Graphics, RAM etc.)

Is this possible?

like image 945
Ray Booysen Avatar asked Jan 26 '09 11:01

Ray Booysen


2 Answers

Every time the user goes through control panel to calculate the Windows Experience Rating, the system creates a new file in %Windows%\Performance\WinSAT\DataStore\

You need to find the most recent file (they are named with the most significant date first, so finding the latest file is trivial).

These files are xml files and are easy to parse with XmlReader or other xml parser.

The section you are interested in is WinSAT\WinSPR and contains all the scores in a single section. E.g.

<WinSAT>
    <WinSPR>
        <SystemScore>3.7</SystemScore> 
        <MemoryScore>5.9</MemoryScore> 
        <CpuScore>5.2</CpuScore> 
        <CPUSubAggScore>5.1</CPUSubAggScore> 
        <VideoEncodeScore>5.3</VideoEncodeScore> 
        <GraphicsScore>3.9</GraphicsScore> 
        <GamingScore>3.7</GamingScore> 
        <DiskScore>5.2</DiskScore> 
    </WinSPR>
...
like image 189
Sam Meldrum Avatar answered Oct 17 '22 04:10

Sam Meldrum


Same with LINQ:

var dirName = Environment.ExpandEnvironmentVariables(@"%WinDir%\Performance\WinSAT\DataStore\");
var dirInfo = new DirectoryInfo(dirName);
var file = dirInfo.EnumerateFileSystemInfos("*Formal.Assessment*.xml")
    .OrderByDescending(fi => fi.LastWriteTime)
    .FirstOrDefault();

if (file == null)
    throw new FileNotFoundException("WEI assessment xml not found");

var doc = XDocument.Load(file.FullName);

Console.WriteLine("Processor: " + doc.Descendants("CpuScore").First().Value);
Console.WriteLine("Memory (RAM): " + doc.Descendants("MemoryScore").First().Value);
Console.WriteLine("Graphics: " + doc.Descendants("GraphicsScore").First().Value);
Console.WriteLine("Gaming graphics: " + doc.Descendants("GamingScore").First().Value);
Console.WriteLine("Primary hard disk: " + doc.Descendants("DiskScore").First().Value);
Console.WriteLine("Base score: " + doc.Descendants("SystemScore").First().Value);
like image 24
SlavaGu Avatar answered Oct 17 '22 04:10

SlavaGu