VBS Script help

Anarchaotical

Junior Member
Apr 30, 2007
5
0
0
I need someone to help me with writing a VBS script that does the following.

1. Will display a message on screen saying "Battery is low, please plug in Laptop."

2. Will have an "Ok" box that will be GREYED out until the laptop is running on AC power.

3. Will have "WARNING" in the titlebar.

I want to run this when the laptop is low on battery so the people know to plug the laptop in.
This has been a HUGE problem at my work and its frustrating me and my co-workers.

Thank you, I will answer any questions you have.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
You can pop the message box from VB script after querying the power state through WMI, but you can't enable the OK button when they plug in the AC, at least not in any graceful way I can think of. For that you'd need an application with a custom dialog written in VB.Net at a minimum.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
What you could do is just loop around the MessageBox and continually pop it open until they click Ok AND the AC Power is on.
 

KLin

Lifer
Feb 29, 2000
30,950
1,076
126
Dim Status
Status = WMITest()
do while Status <> 2
msgbox("Please plug this laptop in you asshole!")
Status = WMITest
Loop
msgbox("Laptop is plugged in!!")

Function WMITest()
Set Items = GetObject("winmgmts:").InstancesOf("Win32_Battery")
For each objItem in Items
wmiTest = objItem.BatteryStatus
Next
Set Items = Nothing
End function


the above wouldn't work to show an alert that a battery the battery is low though.
 

gsellis

Diamond Member
Dec 4, 2003
6,061
0
0
Originally posted by: KLin
"Please plug this laptop in you asshole!"
Somehow, I don't think that location will change the resultant of Win32Battery.Status. And it is bad english. ;)