Is there a way to automatically disconnect a notebook from the eletrical power-supply?

I know this looks like weird and useless, but let me explain...

I'm running Windows Assessment and Deployment Kit (Windows ADK) to make some tests on Windows 8 Preview. One of it's assessment is the "Battery Run Down Test", which tests battery consumption with some procesor load. I'm trying to "automate" in some way this test, I mean, I wish to execute it without any human intervention (such as manually disconecting the eletric power source to leave my notebook running only from batteries to run this assessment).

So, there is some ACPI API, Windows API or even an easy bat shell/VBScript/Powershell command to do this?

Does someone already made something like?

PS: I'm asking this because I couldn't found any answer, but maybe someone here would have any tip...


Solution 1:

This really depends on your power circuit. It's very doubtfully that it would allow you to turn of the charging functionality from the OS. There might be very rare laptops that allow one to do so but I don't think that it is a general feature.

You can however manipulate the state, either as Ava Gailliot suggested or by disablig the device:

As said in the first paragraph: This will make your OS think it's on battery, but it won't actually deplete.


You might have more success looking into a controllable UPS or Power Supply, example here.

Solution 2:

I've been searching the 'net and it looks as if it is possible with WMI Classes although you'll have to implement your own solution. It appears that there is a method SetPowerState that may be able to do what you're asking.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa393485(v=vs.85).aspx

There are many scripts already available online on how to check the battery status of a machine -- they may help you with writing one to turn off the AC power. Here is one such example: http://www.robvanderwoude.com/files/battstat_xp.txt

Solution 3:

Tom suggested a controllable UPS. If you want a much cheaper, kludgier solution, you could get an X10 appliance module and USB transceiver for around $50. You can then use a script or remote login to cut or restore power to the computer.

(apologies for that link -- their website is every bit as eye-searing as it was in 1999.)