Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-27-2017, 04:13 PM   #1
Beta Member
 
Join Date: May 2017
Location: UK
Posts: 4
Default Shutdown when on battery

I am very new to the world of laptops (always been a PC user) so not sure if this is possible but I thought I'd ask.
I have a laptop that runs on AC power for half of the day doing various tasks. If there was a power cut and I am about (within the building for example) I would quickly come and shutdown the laptop without the battery completely being drained running this task. My question is, is there anyway a batch, vbs or a free program that I can use so when I am not about, checks/monitors to see what the power source is and when a power source has changed from AC to battery mode, within 2 minutes being on battery, safely runs a shutdown command (shutdown -s) so that at least it shutdowns correctly and not through a battery been drained and damaging the HDD and the laptop. I am on XP but it's going to be soon replaced by Windows 7. I am new to programming so please bear with me if you do have any batches or vbs?
Many thanks.
__________________

jc001 is offline   Reply With Quote
Old 05-28-2017, 01:25 AM   #2
BSOD
 
Join Date: Feb 2016
Location: US
Posts: 963
Default Re: Shutdown when on battery

All Windows laptops can be configured to provide you with various low-battery warnings. Furthermore, you can configure Windows to automatically hibernate or shut down your laptop when the battery gets way too low. In Windows XP, follow these directions to set various battery warnings:

Open the Control Panel’s Power Options icon.
Click the Alarms tab.
Place a check mark by the item Activate Low Battery Alarm When Power Level Reaches.
Use the slider to set the battery percentage level for the Low Battery alarm.
Ten percent seems like a good level.
Click the Alarm Actions button.
Choose what happens when the alarm kicks in.
For example, specify Sound Alarm or Display Message. Add an action, such as Hibernate, Sleep, or Shut Down.
Click OK to close the Alarm Actions dialog box.
Repeat Steps 3 through 7 for the Critical Battery alarm.
Click OK to close the Power Options Properties dialog box.

It might make no sense to have options for low and critical battery levels when the laptop is plugged in, but consider what happens when the battery is charging: If you plug in a laptop when its battery is low and the Plugged In setting for Critical Battery Action is set to Shut Down, the laptop turns itself off even when it’s plugged in.
__________________

Technician is offline   Reply With Quote
Old 05-28-2017, 03:12 AM   #3
Beta Member
 
Join Date: May 2017
Location: UK
Posts: 4
Default Re: Shutdown when on battery

Many thanks for the reply. Is this not possible via a batch or a vbs script that monitors battery level change and then after a 2% drop shuts down the laptop down?
jc001 is offline   Reply With Quote
Old 05-28-2017, 02:20 PM   #4
Daemon Poster
 
AMD_man's Avatar
 
Join Date: Dec 2016
Location: Argentina
Posts: 749
Default Re: Shutdown when on battery

Quote:
Originally Posted by jc001 View Post
Many thanks for the reply. Is this not possible via a batch or a vbs script that monitors battery level change and then after a 2% drop shuts down the laptop down?
Did the Control Pannel settings not work for you?
__________________
"I have taken a liking to thee. And I owe thee much for thy service to Artorias. Now watch, and see how Gough hunts dragons."
AMD_man is offline   Reply With Quote
Old 05-28-2017, 05:39 PM   #5
Beta Member
 
Join Date: May 2017
Location: UK
Posts: 4
Default Re: Shutdown when on battery

Yes and no. I saw the settings in control panel but I was asking/checking if it is possible via a script instead. Since the reply, I have found a batch that monitors battery level change every 10 mins (which works) and then when the battery does change % it writes an event and then the event will trigger on an event ID a shutdown command. Since posting this I have learnt I will now be running via a pc instead of a laptop so the control panel is changed altogether (boss now wants me on a pc instead) which will run on a UPS. However, the UPS software (Powerchute) wont install on the pc (someone elses problem not mine so reasons I dont know so cant ask why it wont) my question now is I still require it to be shutdown via command, so if running a batch on a pc every 10 mins will this be OK or will it slow down my pc or affect the CPU in the process in any way.
jc001 is offline   Reply With Quote
Old 05-28-2017, 06:40 PM   #6
Daemon Poster
 
AMD_man's Avatar
 
Join Date: Dec 2016
Location: Argentina
Posts: 749
Default Re: Shutdown when on battery

Quote:
Originally Posted by jc001 View Post
Yes and no. I saw the settings in control panel but I was asking/checking if it is possible via a script instead. Since the reply, I have found a batch that monitors battery level change every 10 mins (which works) and then when the battery does change % it writes an event and then the event will trigger on an event ID a shutdown command. Since posting this I have learnt I will now be running via a pc instead of a laptop so the control panel is changed altogether (boss now wants me on a pc instead) which will run on a UPS. However, the UPS software (Powerchute) wont install on the pc (someone elses problem not mine so reasons I dont know so cant ask why it wont) my question now is I still require it to be shutdown via command, so if running a batch on a pc every 10 mins will this be OK or will it slow down my pc or affect the CPU in the process in any way.
Well it'll take up some resources. Your CPU will determine how much it affects other tasks. Your storage drives and RAM will also be used but all depends on how good they are. Running a simple script shouldn't take so much resources thoug. What are your specs?
AMD_man is offline   Reply With Quote
Old 07-21-2017, 09:01 PM   #7
Fully Optimized
 
Draygoes's Avatar
 
Join Date: Nov 2014
Location: United States
Posts: 1,653
Default Re: Shutdown when on battery

You will want to use Autoit for this. You can read progressbars, interfaces, and system processes. Depending on what programs you are running you should be able to deal with your problem. Its very basic (that is why its called "Basic Like"), but very effective.
Bit of a learning curve but not too difficult.
Also, you might consider the Ram load from compiled scripts. If your only going to be using it on your own machine, that wont matter to much as you may not need to compile anything. Still, keep all that in mind.
EDIT: And also ask questions on the forum. The more you ask the faster you will learn.

I hope this helps.
__________________
Will have a youtube channel up soon. Link will be here if I remember.
Draygoes is offline   Reply With Quote
Old 08-10-2017, 10:45 AM   #8
Beta Member
 
Join Date: May 2017
Location: UK
Posts: 4
Default Re: Shutdown when on battery

Many thanks for all the replies. I have sorted it and with some testing there is a script that runs every x min that checks if it's on AC or the battery power. If it's on the battery, it will shutdown the laptop within a certain timeout. So far it hasn't shown any problems with the CPU and resources and has been working OK. Thanks again all.

Note: That link you provided Draygoes takes you to http://www.computerforums.org/forums...toitscript.com. I did come across the correct link however. Thanks.
__________________

jc001 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 02:32 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0