このエントリーをはてなブックマークに追加


VBScriptでCPU名、CPU使用率、CPUクロックを取得する方法

本資料は、VBScriptでCPUの各種情報を取得するサンプルスクリプトを記します。


CPU情報を取得する

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

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

実行結果

01.png

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



添付ファイル: file01.png 572件 [詳細] filecpu.zip 530件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2015-03-20 (金) 22:50:38