Win32_PageFileUsage WMI call returning 0 for CurrentUsage
Posted
by Ryan Duffield
on Stack Overflow
See other posts from Stack Overflow
or by Ryan Duffield
Published on 2010-06-09T00:20:57Z
Indexed on
2010/06/09
1:02 UTC
Read the original article
Hit count: 175
I am querying for the current page file usage on Windows-based systems. This is meant to run on the .NET Framework, version 2.0 SP1 and has been tested (and works!) on Windows Vista, Windows 7, Windows Server 2003 R2 and Windows Server 2008.
On Windows Server 2003 SP2 (original release, not R2) it appears to return 0:
using (var query = new ManagementObjectSearcher("SELECT CurrentUsage FROM Win32_PageFileUsage"))
{
foreach (ManagementBaseObject obj in query.Get())
{
uint used = (uint)obj.GetPropertyValue("CurrentUsage");
return used;
}
}
This is simply returning the results from the first row returned for the WMI call. Even when a page file is being used, it returns 0. What causes the result to be 0 when it should be returning a larger value?
It may be something specific to the machine in question, and could have nothing to do with the operating system version. I've also tried this with and without elevated privileges with the same results.
© Stack Overflow or respective owner