views:

65

answers:

1

I have some simple code:

ManagementObjectSearcher searcher = 
    new ManagementObjectSearcher("select * from Win32_UninterruptiblePowerSupply");

ManagementObjectCollection items = searcher.Get();

foreach (ManagementObject item in items)
{
    // Some code here...
}

The "items" object is semi-null. It's actually an object, but a call to .Count or anything else throws an exception.

I do have a standard USB-compliant UPS hooked up, this is Windows 7, and I'm using Visual Studio 2010 on a 64-bit machine. I did add a manifest and requireAdministrator too.

Other WMI classes work, but this one doesn't. I'm out of ideas - help!

+2  A: 

Well from the MSDN documentation for Win32_UninterruptiblePowerSupply it states that:

Beginning with Windows Vista, this class is obsolete and not available because the UPS service is no longer available. This service worked with serially attached UPS devices, not USB devices.

Garett
Ahh - I didn't catch that, thanks! Any ideas on how I DO capture USB UPS information??
Robert Seder
You may want to take a look at the Win32_Battery and Win32_PortableBattery classes.
Garett
Yeah - those are both empty. I never did figure out how to do this. Thanks anyhow...
Robert Seder