Word Count: 533 Date: Fri, 19 Jun 2009 2:12 AM
Using VBScript - WMI - to query cooling fan statistics
The following script displays status information for all (monitorable) cooling fans on a Windows system. This includes power supply fans, cpu fans, case fans, etc.
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Fan")
For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Active Cooling: " & objItem.ActiveCooling
Wscript.Echo "Availability: " & availability_name(objItem.Availability)
Wscript.Echo "Status Information: " & status_info(objItem.StatusInfo)
Next
Function availability_name(availability_code)
Dim code(18)
code(0) = ""
code(1) = "Other"
code(2) = "Unknown"
code(3) = "Running or Full Power"
code(4) = "Warning"
code(5) = "In Test"
code(6) = "Not Applicable"
code(7) = "Power Off"
code(8) = "Off Line"
code(9) = "Off Duty"
code(10) = "Degraded"
code(11) = "Not Installed"
code(12) = "Install Error"
code(13) = "Power Save - Unknown"
code(14) = "Power Save - Low Power Mode"
code(15) = "Power Save - Standby"
code(16) = "Power Cycle"
code(17) = "Power Save - Warning"
availability_name = code(availability_code)
End Function
Function status_info(status_code)
Dim code(6)
code(0) = ""
code(1) = "Other"
code(2) = "Unknown"
code(3) = "Enabled"
code(4) = "Disabled"
code(5) = "Not Applicable"
status_info = code(status_code)
End Function
What Is VBScript?
Microsoft Visual Basic Scripting Edition brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet Information Service.
Easy to Use and Learn
If you already know Visual Basic or Visual Basic for Applications (VBA), VBScript will be very familiar. Even if you do not know Visual Basic, once you learn VBScript, you are on your way to programming with the whole family of Visual Basic languages. Although you can learn about VBScript in just these few Web pages, they do not teach you how to program. To learn programming, take a look at Step by Step books available from Microsoft Press.
Windows Script
VBScript talks to host applications using Windows Script. With Windows Script, browsers and other host applications do not require special integration code for each scripting component. Windows Script enables a host to compile scripts, obtain and call entry points, and manage the namespace available to the developer. With Windows Script, language vendors can create standard language run times for scripting. Microsoft will provide run-time support for VBScript. Microsoft is working with various Internet groups to define the Windows Script standard so that scripting engines can be interchangeable. Windows Script is used in Microsoft® Internet Explorer and in Microsoft® Internet Information Service.
VBScript in Other Applications and Browsers
As a developer, you can license VBScript source implementation at no charge for use in your products. Microsoft provides binary implementations of VBScript for the 32-bit Windows® API, the 16-bit Windows API, and the Macintosh®. VBScript is integrated with World Wide Web browsers. VBScript and Windows Script can also be used as a general scripting language in other applications.
About the Author
ApplicationBistro.com is your one stop shop for buyiny and selling custom/one-off applications for any and all of your computing needs.
Find out more at http://applicationbistro.com.
NOTE: There are no catches, we don't make money unless you make money... Give us a try and if you are not convinced, post your experiencience on our forum. We want to hear from happy and "unhappy" customers, and will strive to make your experience with us better, given the odd chance that you have a bad experience with the services provided by us or any of our affiliates. We stand behind our community of developers but, if you are not satisfied with the product you are given, our staff will work to ensure that you are completly satisfied by the end of the transaction. Try us and find out.
Rate, comment or bookmark this article
Comments 
No comments posted.
Add Comment
Popular Articles in this cathegory
1: SSH tunneling in your application2: How to Become a Programmer
How to learn computer programming quickly by shaving years off your learning curve, how to prepare your resume so you get noticed by hiring managers, how to prepare for and excel at technical job interviews so you get job offers more easily and how to consistently gain the kind of programming experience that makes you a rockstar programmer.
3: 9 Free Webmaster Tools You Can Fall In Love With
4: Analysis of a Mandatory Access Restriction System for Oracle DBMS
5: Double Text - Starting The Program From Within Visual Studio
This article is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License.

