How do i check whether my laptop is on battery or on cable
I have a package which decrypts hard disk and then encrypts. This will be taking a lot of time. So, we do not want it to be installed when the laptop is on battery. How do i check whether the machine is on battery or cable.
Answers (2)
It kind of depends how you are deploying your package, but there are at least a couple of ways to do it (assuming Windows):
http://blogs.technet.com/b/heyscriptingguy/archive/2007/04/09/how-can-i-tell-whether-a-laptop-computer-is-running-off-batteries.aspx
http://blogs.technet.com/b/heyscriptingguy/archive/2010/07/31/using-windows-powershell-to-determine-if-a-laptop-is-on-battery-power.aspx
Check this link: http://lmgtfy.com/?q=wmi+query+on+mains+or+battery&l=1
You will need to use WMI...