Solved Battery Power Code

Hewlett-packard Ms windows server 2003 r...
September 12, 2011 at 11:22:45
Specs: Windows XP, Quad Core / 2Gig
I am trying to make scripts that will execute when the system is on UPS or Battery Power. It will run on a Windows 2008 server when I am done. I have tried the following code found at:

Dim psBattery As PowerStatus = SystemInformation.PowerStatus
Dim perFull As Single = psBattery.BatteryLifePercent

'Show the remaining battery power in percentages

MsgBox("Total battery power remaining: " & perFull * 100 & "%")

'Is the battery charging?

If psBattery.PowerLineStatus = PowerLineStatus.Online Then
    MsgBox("Battery charge status: Charging")
ElseIf psBattery.PowerLineStatus = PowerLineStatus.Offline Then
    MsgBox("Battery charge status: Not charging")
End If

But it blows up on Line 1 char 15 saying it is expecting an end of statement.

Any help would be appreciated.

See More: Battery Power Code

Report •

September 12, 2011 at 12:33:53
Turns out I am going to have to compile this because SystemInformation is not available in VBS. If you know of any other code that will do this, let me know.

Report •

September 13, 2011 at 09:07:30
✔ Best Answer

Report •

September 14, 2011 at 11:17:55
Thanks. I put the Win32_Battery API in a language I know (Delphi Pascal) and came up with something that works. Thanks Again.

Report •
Related Solutions

Ask Question