• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VBS Script help

Anarchaotical

Junior Member
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.
 
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.
 
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.
 
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.
 
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. 😉
 
Back
Top