battery

所属分类:其他小程序
开发工具:VBScript
文件大小:3KB
下载次数:4
上传日期:2009-02-03 18:42:17
上 传 者z_survivor
说明:  This is a simple script example for get battery information.

文件列表:
battery\battery_info.out (1323, 2008-12-03)
battery\battery_info.vbs (958, 2008-12-03)
battery (0, 2009-02-03)

Smart Batteries This article describes the smart battery system and provides a simple script that lets you extract battery information from your laptop. Many laptop batteries can provide you with a wealth of information about their current performance. These are the so-called smart batteries. Smart batteries are smart because they contain microprocessor circuitry that can interogate the battery state to provide suitable information. There is a wide variety of data that can be offered, although not all systems and not all batteries provide all of this. The Smart Battery System (SBS) An industry standard call the Smart Battery System (SBS) Specification exists, and for those systems that conform fully to it it provides a wealth of information. You may find your battery or system (either your laptop hardware or the operating system you run) does not let you get all this information. However, it is still possible to get quite a lot of information when you query your battery. The SBS specification defines 34 different data values. This large number is broken down into six categories, these being: Measurement information, such as voltage and current usage Capacity information, such as how much charge is present and the maximum charge that can be stored The time remaining, to full discharge and to full charge based on capacity and other performance data Alerts and broadcasts, including when a critically low charge level is reached The mode, status and error reporting, such as whether the battery is charging or discharging, and if the battery detected any error in its operation Historical and identification, including the number of times it has been through a full charging cycle, what it's design capacity was, and information identifying the manufacturer and battery type This information allows operating system designers and programmers who write specialist applications that need to understand the laptop's battery status access to a rich collection of data that they can use to their advantage. To illustrate what sort of information is available if you have a Windows operating system running on your laptop you can download the battery_info.vbs script file and execute the script in a command shell. This script has been written to extract the core information. Note that if, when you click on the above link, it opens the file rather than asking you to save it, you should instead right-click the link and then choose the save-as option. You can view further information about this script. You can then use this information for any use you see fit. For example, you can run the script at set times, such as when you boot your laptop, and save the data for comparison with the collection of previous such data. Over time this will give you a picture of how your battery is performing and will help you to access when you need to think about replacing it. The script is written using Microsoft's Windows scripting language. In order to run this you will need a copy of cscript.exe; you will very likely have this already installed on your laptop, as Microsoft provides this as standard. On the next page is a sample of the sort of output you can expect from this script. This was created on a Toshiba laptop running Vista, with two CPUs. Different systems will produce different results, depending on the information that is available to the operating system. How to run the script If you are not familiar with working with command line tools, then do the following to get your own version of the output. First download the script file above and save to disk. This is just a text file, so you can use a program such as Notepad to view its contents. Once you have saved it on your laptop you need to know how to find it when you work from a commnad prompt. Now start a command prompt. The easiest way is to do the following: For XP users click on Start, then Run, finally enter cmd and click OK For Vista users click on Start, then All Programs, Accessories and finally Command Prompt Now you need to find out where you saved the script file. Again, the easiest way is to enter this command: dir /s \battery_info.vbs This will do a recursive search from the top of your current drive. When it finds it it will report the drive and the path. For example, you may have saved it on your desktop: C:\>dir /s \battery_info.vbs Volume in drive C is Vista Volume Serial Number is 7054-9962 Directory of C:\Users\Test\Desktop 09/07/2008 23:21 958 battery_info.vbs 1 File(s) 958 bytes Total Files Listed: 1 File(s) 958 bytes 0 Dir(s) 9,584,889,856 bytes free C:\> Now to run this script from the command line simply use this command: cscript c:\users\test\desktop\battery_info.vbs If you want to save it you can send the output of this script to a file. Here we first use the cd command to change directory to c:\users\test\desktop. This is purely for convenience, otherwise the cscript command would stretch off across the page. The output file is in the same directory as the script file. cd c:\users\test\desktop cscript battery_info.vbs > battery_info.out Next we look at the output from the script, and in more detail at each of the objects the script prints out.

近期下载者

相关文件


收藏者