#navi(../)
* VBScriptでCPU名、CPU使用率、CPUクロックを取得する方法 [#lb8c3b79]
本資料は、VBScriptでCPUの各種情報を取得するサンプルスクリプトを記します。

#contents
#htmlinsertpcsp(win-top.html,win-sp.html)

* CPU情報を取得する [#y2bf7b97]
以下のサンプルスクリプトでCPU情報を取得することができます。~
サンプルスクリプトでは、CPU名、CPU使用率、CPUクロックを取得しています。

#ref(cpu.zip)
 Option Explicit
 
 Dim oClassSet, oClass, oLocator, oService
 Dim szMsg
 
 Set oLocator = WScript.CreateObject("WbemScripting.SWbemLocator")
 Set oService = oLocator.ConnectServer
 Set oClassSet = oService.ExecQuery("SELECT * FROM Win32_Processor")
 For Each oClass In oClassSet
   MsgBox "CPU Name: " & oClass.Name & vbCrLF & _
          "CPU Usage[%]: " & oClass.LoadPercentage & vbCrLf & _
          "CPU Clock : " & oClass.CurrentClockSpeed
 Next
 
 Set oClassSet = Nothing
 Set oClass = Nothing
 Set oService = Nothing
 Set oLocator = Nothing

実行結果
#ref(01.png)

以上、VBScriptでCPU情報を取得する方法でした。

#htmlinsertpcsp(win-btm.html,win-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS