WMI Fun !! 〜 WMI に興味がある方・システム管理者は必見です! 〜 |
|
![]() |
WMI Fun !! > WMI Sample (VBS) > CPU の温度を取得する |
CPU の温度を取得する: MSAcpi_ThermalZoneTemperature - WMI Sample (VBS)Topics
CPU の温度を取得するサンプルです。
Sample Code
Option Explicit
'WMIにて使用する各種オブジェクトを定義・生成する。 Dim oClassSet Dim oClass Dim oLocator Dim oService Dim sMesStr 'ローカルコンピュータに接続する。 Set oLocator = Wscript.CreateObject("WbemScripting.SWbemLocator") Set oService = oLocator.ConnectServer(, "Root\WMI") 'クエリー条件を WQL にて指定する。 Set oClassSet = oService.ExecQuery("Select * From MSAcpi_ThermalZoneTemperature") 'コレクションを解析する。 For Each oClass In oClassSet sMesStr = "インスタンス名: " & oClass.InstanceName & vbCrLf & _ "温度: " & CStr((oClass.CurrentTemperature - 2732) / 10 ) & vbCrLf & vbCrLf Next MsgBox("CPU 温度に関する情報です。" & vbCrLf & vbCrLf & sMesStr) '使用した各種オブジェクトを後片付けする。 Set oClassSet = Nothing Set oClass = Nothing Set oService = Nothing Set oLocator = Nothing
![]() Comment
実行すると現在の CPU の温度を表示します。 ![]() Latest sample information
最近WMI Sampleへ追加したサンプルのご紹介です。
興味のあるサンプル・クラスがありましたら参考にしてみて下さい。 |
ご意見・ご要望・ご感想をこちらのアンケートからお待ちしています |
∧ ページの先頭へ… |