VBS for Windows Management Instrumentation

About WMI

サンプルコードについて

本ページのサンプルはVBSで書かれています。
サンプルコードはテキストファイルにて保存し、拡張子を「vbs」とすることで実行されます。
コマンドプロンプトからの実行では、下記のようにcscriptを明示することで結果を標準出力に反映できます。
>cscript.exe filename.vbs

SQL

ExecQueryを使用することで特定のコレクションのみを取得します。WMIのSQLの詳細は下記を参照のこと
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/sql_for_wmi.asp
'ExecQueryについて
'
'Syntax
Set QfeSet = Service.ExecQuery("Select * From ClassName")

'WHERE
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='CMD.EXE'")
Set QfeSet = Service.ExecQuery("Select * From Win32_NTLogEvent Where RecordNumber<'10'")

'IS
Set QfeSet = Service.ExecQuery("Select * From Win32_SoftwareFeature Where Caption Is Not Null")

'LIKE(XP以降でサポート)
Set QfeSet = Service.ExecQuery("Select * From CIM_DataFile" _
            & " Where Name Like 'C:\\Documents and Settings\\Default User\\Favorites'")

リモート接続する

ConnectServerメソッドに引数を与えます
'ConnectServerメソッドで接続先を指定する
'サンプル
Set Service = Locator.ConnectServer("ComputarName","root\cimv2","UserName","Password")

参考URL

日本語解説サイト
http://wmifun.atinfinity.net/
MSDN
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_classes.asp

Index of Sample Source

Win32_StartupCommand

スタートアップコマンドの一覧を取得

'-----------------------------------
'スタートアップコマンドの一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_StartupCommand")


For Each Qfe In QfeSet
    Ret = Ret & Qfe.User & vbTab & Qfe.Command & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_ExtensionInfoAction

登録された拡張子の一覧を取得

'-----------------------------------
'登録された拡張子の一覧を取得
'※OSにdefaultで登録されているもの(txtなど)は拾えない?
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ExtensionInfoAction")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Extension & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_1394Controller

IEEE1394コントローラ名を取得

'-----------------------------------
'IEEE1394コントローラ名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_1394Controller")

For Each Qfe In QfeSet
    Ret = Qfe.Caption
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

IEEE1394コントローラのデバイスIDを取得

'-----------------------------------
'IEEE1394コントローラのデバイスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_1394Controller")

For Each Qfe In QfeSet
    Ret = Qfe.DeviceID
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

IEEE1394コントローラのステータスを取得

'-----------------------------------
'IEEE1394コントローラのステータスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_1394Controller")

For Each Qfe In QfeSet
    Ret = Qfe.Status
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_VideoController

ビデオコントローラ名を取得

'-----------------------------------
'ビデオコントローラ名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.Caption
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ビデオコントローラのデバイスIDを取得

'-----------------------------------
'ビデオコントローラのデバイスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.DeviceID
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ビデオコントローラのステータスを取得

'-----------------------------------
'ビデオコントローラのステータスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.Status
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ビデオRAMサイズを取得

'-----------------------------------
'ビデオRAMサイズを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.AdapterRAM
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

リフレッシュレートを取得

'-----------------------------------
'リフレッシュレートを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.CurrentRefreshRate
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

現在の画面の色数を取得

'-----------------------------------
'現在の画面の色数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.CurrentNumberOfColors 
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

現在の画面の解像度を取得

'-----------------------------------
'現在の画面の解像度を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.CurrentHorizontalResolution & "×" & Qfe.CurrentVerticalResolution
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ビデオカードドライバのinfファイル名を取得

'-----------------------------------
'ビデオカードドライバのinfファイル名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.InfFilename
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

インストールされたディスプレイドライバ名を取得

'-----------------------------------
'インストールされたディスプレイドライバ名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.InstalledDisplayDrivers
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

最大リフレッシュレートを取得

'-----------------------------------
'最大リフレッシュレートを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.MaxRefreshRate
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

最小リフレッシュレートを取得

'-----------------------------------
'最小リフレッシュレートを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.MinRefreshRate
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ビデオカードのステータスを取得

'-----------------------------------
'ビデオカードのステータスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.Status
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ビデオカードのアーキテクチャを取得

'-----------------------------------
'ビデオカードのアーキテクチャを取得
'
'1 Other  2 Unknown  3 CGA 
'4 EGA  5 VGA  6 SVGA 
'7 MDA  8 HGC  9 MCGA 
'10 8514A  11 XGA 
'12 Linear Frame Buffer 
'160 PC-98 
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.VideoArchitecture
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ビデオメモリのタイプを取得

'-----------------------------------
'ビデオメモリのタイプを取得
'
'1 Other  2 Unknown  3 VRAM 
'4 DRAM  5 SRAM  6 WRAM  7 EDO RAM 
'8 Burst Synchronous DRAM 
'9 Pipelined Burst SRAM 
'10 CDRAM  11 3DRAM 
'12 SDRAM  13 SGRAM 
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.VideoMemoryType
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ビデオカードのチップセットを取得

'-----------------------------------
'ビデオカードのチップセットを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_VideoController")

For Each Qfe In QfeSet
    Ret = Qfe.VideoProcessor
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_CDROMDrive

光学ドライブの型式を取得

'-----------------------------------
'光学ドライブの型式を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_CDROMDrive")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Caption & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

光学ドライブのドライブレターを取得

'-----------------------------------
'光学ドライブのドライブレターを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_CDROMDrive")

For Each Qfe In QfeSet
    Ret = Qfe.Drive
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

光学ドライブのデバイスIDを取得

'-----------------------------------
'光学ドライブのデバイスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_CDROMDrive")

For Each Qfe In QfeSet
    Ret = Qfe.DeviceID
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

光学ドライブにメディアが挿入されているか調べる

'-----------------------------------
'光学ドライブにメディアが挿入されているか調べる
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_CDROMDrive")

For Each Qfe In QfeSet
    Ret = Qfe.MediaLoaded
Next

Wscript.Echo Ret
Wscript.Quit Abs(Ret)

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

光学ドライブの転送レイト(Byte/sec)を調べる

'-----------------------------------
'光学ドライブの転送レイト(Byte/sec)を調べる
'(実測値なのでメディアが入っていること)
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_CDROMDrive")

For Each Qfe In QfeSet
    Ret = Qfe.TransferRate
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

光学メディアのボリューム名を調べる

'-----------------------------------
'光学メディアのボリューム名を調べる
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_CDROMDrive")

For Each Qfe In QfeSet
    Ret = Qfe.VolumeName
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

光学メディアのボリュームシリアルナンバーを調べる

'-----------------------------------
'光学メディアのボリュームシリアルナンバーを調べる
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_CDROMDrive")

For Each Qfe In QfeSet
    Ret = Qfe.VolumeSerialNumber 
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

MicrosoftIE_LanSettings

プロキシの有効・無効を参照

'-----------------------------------
'プロキシの有効・無効を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(, "Root\CIMV2\Applications\MicrosoftIE")
Set QfeSet = Service.ExecQuery("Select * From MicrosoftIE_LanSettings")

For Each Qfe In QfeSet
    Ret = Qfe.Proxy
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロキシサーバのアドレスを取得

'-----------------------------------
'プロキシサーバのアドレスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(, "Root\CIMV2\Applications\MicrosoftIE")
Set QfeSet = Service.ExecQuery("Select * From MicrosoftIE_LanSettings")

For Each Qfe In QfeSet
    Ret = Qfe.ProxyServer
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロキシサーバを使用しないアドレスを取得

'-----------------------------------
'プロキシサーバを使用しないアドレスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(, "Root\CIMV2\Applications\MicrosoftIE")
Set QfeSet = Service.ExecQuery("Select * From MicrosoftIE_LanSettings")

For Each Qfe In QfeSet
    Ret = Qfe.ProxyOverride
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

StdRegProv

レジストリを読み込み

'-----------------------------------
'レジストリを読み込み
'
'-----------------------------------
Option Explicit

Dim Wcls
Dim Locator
Dim Service
Dim Ret

Const HKEY_LOCAL_MACHINE = &H80000002


Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(vbNullString, "root\default")
Set Wcls = Service.Get("StdRegProv")

'文字列値
Wcls.GetStringValue HKEY_LOCAL_MACHINE, _
    "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOwner", Ret

''DWORD値
'Wcls.GetDWORDValue HKEY_LOCAL_MACHINE, _
'    "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "InstallDate", Ret

''バイナリ値
'Dim bRet
'Dim Cnt
'Wcls.GetBinaryValue HKEY_LOCAL_MACHINE, _
'    "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId", bRet
'For Cnt = 0 to Ubound(bRet)
'    Ret = Ret & Hex(bRet(Cnt))
'Next

Wscript.Echo Ret

Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing

レジストリキーの生成

'-----------------------------------
'レジストリキーの生成
'
'-----------------------------------
Option Explicit

Dim Wcls
Dim Locator
Dim Service
Dim Ret

Const HKEY_CURRENT_USER = &H80000001


Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(vbNullString, "root\default")
Set Wcls = Service.Get("StdRegProv")

Ret = Wcls.CreateKey(HKEY_CURRENT_USER, "SoftWare\aaaaaaWMI")

If Ret = 0 Then
    Wscript.Echo "OK"
Else
    Wscript.Echo "NG"
End If

Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing

レジストリのサブキーを列挙

'-----------------------------------
'レジストリのサブキーを列挙
'
'-----------------------------------
Option Explicit

Dim Wcls
Dim Locator
Dim Service
Dim Ret
Dim KeySet
Dim Key

Const HKEY_CURRENT_USER = &H80000001


Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(vbNullString, "root\default")
Set Wcls = Service.Get("StdRegProv")

Wcls.EnumKey HKEY_CURRENT_USER, "SoftWare\Microsoft\Internet Explorer",KeySet

For Each Key In KeySet
    Ret = Ret & Key & vbCrLf
Next

Wscript.Echo Ret

Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing

レジストリの値名を列挙

'-----------------------------------
'レジストリの値名を列挙
'
'
'1 REG_SZ
'2 REG_EXPAND_SZ
'3 REG_BINARY
'4 REG_DWORD
'5 REG_MULTI_SZ
'-----------------------------------
Option Explicit

Dim Wcls
Dim Locator
Dim Service
Dim Ret
Dim NaSet
Dim Na
Dim TySet
Dim Ty
Dim Cnt

Const HKEY_CURRENT_USER = &H80000001


Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(vbNullString, "root\default")
Set Wcls = Service.Get("StdRegProv")

Wcls.EnumValues HKEY_CURRENT_USER, "SoftWare\Microsoft\Internet Explorer",NaSet,TySet

For Cnt = 0 To Ubound(NaSet)
    Ret = Ret & NaSet(Cnt) & vbTab & TySet(Cnt) & vbCrLf
Next

Wscript.Echo Ret

Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing

レジストリに書き込み

'-----------------------------------
'レジストリに書き込み
'
'-----------------------------------
Option Explicit

Dim Wcls
Dim Locator
Dim Service
Dim Ret

Const HKEY_CURRENT_USER = &H80000001


Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(vbNullString, "root\default")
Set Wcls = Service.Get("StdRegProv")

Ret = Wcls.SetStringValue(HKEY_CURRENT_USER, "SoftWare\aaaaaWMI","aaaaaa","テスト文字列")

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If


Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing

レジストリの値を削除

'-----------------------------------
'レジストリの値を削除
'
'-----------------------------------
Option Explicit

Dim Wcls
Dim Locator
Dim Service
Dim Ret

Const HKEY_CURRENT_USER = &H80000001


Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(vbNullString, "root\default")
Set Wcls = Service.Get("StdRegProv")

Ret = Wcls.DeleteValue(HKEY_CURRENT_USER, "SoftWare\aaaaaaWMI","aaaaaa")

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If


Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing

レジストリキーを削除

'-----------------------------------
'レジストリキーを削除
'
'-----------------------------------
Option Explicit

Dim Wcls
Dim Locator
Dim Service
Dim Ret

Const HKEY_CURRENT_USER = &H80000001


Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(vbNullString, "root\default")
Set Wcls = Service.Get("StdRegProv")

Ret = Wcls.DeleteKey(HKEY_CURRENT_USER, "SoftWare\aaaaaaWMI")

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If


Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing


Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing

CIM_LogicalDevice

正常動作していないデバイスの一覧を取得

'-----------------------------------
'正常動作していないデバイスの一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_LogicalDevice " _
            & "Where Not (Status='OK' or Status='' or Status=Null)")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Caption & vbTab & Qfe.Status & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

デバイスIDの一覧を取得

'-----------------------------------
'デバイスIDの一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_LogicalDevice")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.DeviceID & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

動作中のデバイス一覧を取得

'-----------------------------------
'動作中のデバイス一覧を取得
'Availability
'1 Other. 2 Unknown. 3 Running/full power. 4 Warning. 5 Testing. 
'6 Not applicable. 7 Power off. 8 Offline. 9 Off duty. 
'10 Degraded. 11 Not installed. 12 Install error. 13-17 Power save. 
'18 Paused. 19 Not ready. 20 Not configured. 21 Quiesced. 
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_LogicalDevice Where Availability=3")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Caption & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_Battery

バッテリーの電圧を取得

'-----------------------------------
'バッテリーの電圧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Battery")

For Each Qfe In QfeSet
    Ret = Qfe.DesignVoltage
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

バッテリーの残り使用時間を取得

'-----------------------------------
'バッテリーの残り使用時間を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Battery")

For Each Qfe In QfeSet
    Ret = Qfe.EstimatedRunTime
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_ScheduledJob

スケジュール(ATコマンド)の一覧を取得

'-----------------------------------
'スケジュール(ATコマンド)の一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ScheduledJob")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.StartTime & vbTab & Qfe.JobStatus & vbTab & Qfe.Command & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

スケジュール(AT)の追加

'-----------------------------------
'スケジュールの追加
'
'-----------------------------------
Option Explicit

Dim Wcls
Dim Locator
Dim Service
Dim Ret
Dim ID

Ret = -1

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set Wcls = Service.Get("Win32_ScheduledJob")

Ret = Wcls.Create("mspaint.exe", "********123000.000000-900", True, , , , ID)

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing

JobIDを指定してスケジュールの削除

'-----------------------------------
'JobIDを指定してスケジュールの削除
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Ret = -1

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ScheduledJob Where JobID='1'")

For Each Qfe In QfeSet
    Ret = Qfe.Delete
Next

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set Wcls = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_SCSIController

SCSIコントローラ名を取得

'-----------------------------------
'SCSIコントローラ名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_SCSIController")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Name & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

SCSIコントローラのデバイスIDを取得

'-----------------------------------
'SCSIコントローラのデバイスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_SCSIController")

For Each Qfe In QfeSet
    Ret = Qfe.DeviceID
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

SCSIコントローラのステータスを取得

'-----------------------------------
'SCSIコントローラのステータスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_SCSIController")

For Each Qfe In QfeSet
    Ret = Qfe.Status
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_USBController

USBコントローラ名を取得

'-----------------------------------
'USBコントローラ名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_USBController")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Name & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

USBコントローラのデバイスIDを取得

'-----------------------------------
'USBコントローラのデバイスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_USBController")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.DeviceID & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

USBコントローラのステータスを取得

'-----------------------------------
'USBコントローラのステータスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_USBController")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Name & VbTab & Qfe.Status & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_SoundDevice

サウンドデバイス名を取得

'-----------------------------------
'サウンドデバイス名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_SoundDevice")

For Each Qfe In QfeSet
    Ret = Qfe.Name
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サウンドボードのデバイスIDを取得

'-----------------------------------
'サウンドボードのデバイスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_SoundDevice")

For Each Qfe In QfeSet
    Ret = Qfe.DeviceID
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サウンドボードのステータスを取得

'-----------------------------------
'サウンドボードのステータスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_SoundDevice")

For Each Qfe In QfeSet
    Ret = Qfe.Status
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_PortConnector

ポートコネクタの一覧を取得

'-----------------------------------
'ポートコネクタの一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_PortConnector")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.ExternalReferenceDesignator & Qfe.InternalReferenceDesignator & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

コネクタの種類を取得

'-----------------------------------
'コネクタの種類を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_PortConnector")


For Each Qfe In QfeSet
    Select Case Qfe.PortType
    Case 0
        Ret = Ret & "Unknown " & vbCrLf
    Case 1
        Ret = Ret & "Other " & vbCrLf
    Case 2
        Ret = Ret & "Male " & vbCrLf
    Case 3
        Ret = Ret & "Female " & vbCrLf
    Case 4
        Ret = Ret & "Shielded " & vbCrLf
    Case 5
        Ret = Ret & "Unshielded " & vbCrLf
    Case 6
        Ret = Ret & "SCSI (A) High-Density (50 pins) " & vbCrLf
    Case 7
        Ret = Ret & "SCSI (A) Low-Density (50 pins) " & vbCrLf
    Case 8
        Ret = Ret & "SCSI (P) High-Density (68 pins) " & vbCrLf
    Case 9
        Ret = Ret & "SCSI SCA-I (80 pins) " & vbCrLf
    Case 10
        Ret = Ret & "SCSI SCA-II (80 pins) " & vbCrLf
    Case 11
        Ret = Ret & "SCSI Fibre Channel (DB-9, Copper) " & vbCrLf
    Case 12
        Ret = Ret & "SCSI Fibre Channel (Fibre) " & vbCrLf
    Case 13
        Ret = Ret & "SCSI Fibre Channel SCA-II (40 pins) " & vbCrLf
    Case 14
        Ret = Ret & "SCSI Fibre Channel SCA-II (20 pins) " & vbCrLf
    Case 15
        Ret = Ret & "SCSI Fibre Channel BNC " & vbCrLf
    Case 16
        Ret = Ret & "ATA 3-1/2 Inch (40 pins) " & vbCrLf
    Case 17
        Ret = Ret & "ATA 2-1/2 Inch (44 pins) " & vbCrLf
    Case 18
        Ret = Ret & "ATA-2 " & vbCrLf
    Case 19
        Ret = Ret & "ATA-3 " & vbCrLf
    Case 20
        Ret = Ret & "ATA/66 " & vbCrLf
    Case 21
        Ret = Ret & "DB-9 " & vbCrLf
    Case 22
        Ret = Ret & "DB-15 " & vbCrLf
    Case 23
        Ret = Ret & "DB-25 " & vbCrLf
    Case 24
        Ret = Ret & "DB-36 " & vbCrLf
    Case 25
        Ret = Ret & "RS-232C " & vbCrLf
    Case 26
        Ret = Ret & "RS-422 " & vbCrLf
    Case 27
        Ret = Ret & "RS-423 " & vbCrLf
    Case 28
        Ret = Ret & "RS-485 " & vbCrLf
    Case 29
        Ret = Ret & "RS-449 " & vbCrLf
    Case 30
        Ret = Ret & "V.35 " & vbCrLf
    Case 31
        Ret = Ret & "X.21 " & vbCrLf
    Case 32
        Ret = Ret & "IEEE-488 " & vbCrLf
    Case 33
        Ret = Ret & "AUI " & vbCrLf
    Case 34
        Ret = Ret & "UTP Category 3 " & vbCrLf
    Case 35
        Ret = Ret & "UTP Category 4 " & vbCrLf
    Case 36
        Ret = Ret & "UTP Category 5 " & vbCrLf
    Case 37
        Ret = Ret & "BNC " & vbCrLf
    Case 38
        Ret = Ret & "RJ11 " & vbCrLf
    Case 39
        Ret = Ret & "RJ45 " & vbCrLf
    Case 40
        Ret = Ret & "Fiber MIC " & vbCrLf
    Case 41
        Ret = Ret & "Apple AUI " & vbCrLf
    Case 42
        Ret = Ret & "Apple GeoPort " & vbCrLf
    Case 43
        Ret = Ret & "PCI " & vbCrLf
    Case 44
        Ret = Ret & "ISA " & vbCrLf
    Case 45
        Ret = Ret & "EISA " & vbCrLf
    Case 46
        Ret = Ret & "VESA " & vbCrLf
    Case 47
        Ret = Ret & "PCMCIA " & vbCrLf
    Case 48
        Ret = Ret & "PCMCIA Type I " & vbCrLf
    Case 49
        Ret = Ret & "PCMCIA Type II " & vbCrLf
    Case 50
        Ret = Ret & "PCMCIA Type III " & vbCrLf
    Case 51
        Ret = Ret & "ZV Port " & vbCrLf
    Case 52
        Ret = Ret & "CardBus " & vbCrLf
    Case 53
        Ret = Ret & "USB " & vbCrLf
    Case 54
        Ret = Ret & "IEEE 1394 " & vbCrLf
    Case 55
        Ret = Ret & "HIPPI " & vbCrLf
    Case 56
        Ret = Ret & "HSSDC (6 pins) " & vbCrLf
    Case 57
        Ret = Ret & "GBIC " & vbCrLf
    Case 58
        Ret = Ret & "DIN " & vbCrLf
    Case 59
        Ret = Ret & "Mini-DIN " & vbCrLf
    Case 60
        Ret = Ret & "Micro-DIN " & vbCrLf
    Case 61
        Ret = Ret & "PS/2 " & vbCrLf
    Case 62
        Ret = Ret & "Infrared " & vbCrLf
    Case 63
        Ret = Ret & "HP-HIL " & vbCrLf
    Case 64
        Ret = Ret & "Access.bus " & vbCrLf
    Case 65
        Ret = Ret & "NuBus " & vbCrLf
    Case 66
        Ret = Ret & "Centronics " & vbCrLf
    Case 67
        Ret = Ret & "Mini-Centronics " & vbCrLf
    Case 68
        Ret = Ret & "Mini-Centronics Type-14 " & vbCrLf
    Case 69
        Ret = Ret & "Mini-Centronics Type-20 " & vbCrLf
    Case 70
        Ret = Ret & "Mini-Centronics Type-26 " & vbCrLf
    Case 71
        Ret = Ret & "Bus Mouse " & vbCrLf
    Case 72
        Ret = Ret & "ADB " & vbCrLf
    Case 73
        Ret = Ret & "AGP " & vbCrLf
    Case 74
        Ret = Ret & "VME Bus " & vbCrLf
    Case 75
        Ret = Ret & "VME64 " & vbCrLf
    Case 76
        Ret = Ret & "Proprietary " & vbCrLf
    Case 77
        Ret = Ret & "Proprietary Processor Card Slot " & vbCrLf
    Case 78
        Ret = Ret & "Proprietary Memory Card Slot " & vbCrLf
    Case 79
        Ret = Ret & "Proprietary I/O Riser Slot " & vbCrLf
    Case 80
        Ret = Ret & "PCI-66MHZ " & vbCrLf
    Case 81
        Ret = Ret & "AGP2X " & vbCrLf
    Case 82
        Ret = Ret & "AGP4X " & vbCrLf
    Case 83
        Ret = Ret & "PC-98 " & vbCrLf
    Case 84
        Ret = Ret & "PC-98-Hireso " & vbCrLf
    Case 85
        Ret = Ret & "PC-H98 " & vbCrLf
    Case 86
        Ret = Ret & "PC-98Note " & vbCrLf
    Case 87
        Ret = Ret & "PC-98Full " & vbCrLf
    Case 88
        Ret = Ret & "SSA SCSI " & vbCrLf
    Case 89
        Ret = Ret & "Circular " & vbCrLf
    Case 90
        Ret = Ret & "On Board IDE Connector " & vbCrLf
    Case 91
        Ret = Ret & "On Board Floppy Connector " & vbCrLf
    Case 92
        Ret = Ret & "9 Pin Dual Inline " & vbCrLf
    Case 93
        Ret = Ret & "25 Pin Dual Inline " & vbCrLf
    Case 94
        Ret = Ret & "50 Pin Dual Inline " & vbCrLf
    Case 95
        Ret = Ret & "68 Pin Dual Inline " & vbCrLf
    Case 96
        Ret = Ret & "On Board Sound Connector " & vbCrLf
    Case 97
        Ret = Ret & "Mini-jack " & vbCrLf
    Case 98
        Ret = Ret & "PCI-X " & vbCrLf
    Case 99
        Ret = Ret & "Sbus IEEE 1396-1993 32 bit " & vbCrLf
    Case 100
        Ret = Ret & "Sbus IEEE 1396-1993 64 bit " & vbCrLf
    Case 101
        Ret = Ret & "MCA " & vbCrLf
    Case 102
        Ret = Ret & "GIO " & vbCrLf
    Case 103
        Ret = Ret & "XIO " & vbCrLf
    Case 104
        Ret = Ret & "HIO " & vbCrLf
    Case 105
        Ret = Ret & "NGIO " & vbCrLf
    Case 106
        Ret = Ret & "PMC " & vbCrLf
    Case 107
        Ret = Ret & "MTRJ " & vbCrLf
    Case 108
        Ret = Ret & "VF-45 " & vbCrLf
    Case 109
        Ret = Ret & "Future I/O " & vbCrLf
    Case 110
        Ret = Ret & "SC " & vbCrLf
    Case 111
        Ret = Ret & "SG " & vbCrLf
    Case 112
        Ret = Ret & "Electrical " & vbCrLf
    Case 113
        Ret = Ret & "Optical " & vbCrLf
    Case 114
        Ret = Ret & "Ribbon " & vbCrLf
    Case 115
        Ret = Ret & "GLM " & vbCrLf
    Case 116
        Ret = Ret & "1x9 " & vbCrLf
    Case 117
        Ret = Ret & "Mini SG " & vbCrLf
    Case 118
        Ret = Ret & "LC " & vbCrLf
    Case 119
        Ret = Ret & "HSSC " & vbCrLf
    Case 120
        Ret = Ret & "VHDCI Shielded (68 pins) " & vbCrLf
    Case 121
        Ret = Ret & "InfiniBand " & vbCrLf
    End Select
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_PointingDevice

マウスの種類を取得

'-----------------------------------
'マウスの種類を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_PointingDevice")

For Each Qfe In QfeSet
    Ret = Qfe.Description & vbTab & Qfe.Manufacturer
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

マウスのデバイスIDを取得

'-----------------------------------
'マウスのデバイスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_PointingDevice")

For Each Qfe In QfeSet
    Ret = Qfe.DeviceID
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

マウスのステータスを取得

'-----------------------------------
'マウスのステータスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_PointingDevice")

For Each Qfe In QfeSet
    Ret = Qfe.status
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_Keyboard

キーボードの種類を取得

'-----------------------------------
'キーボードの種類を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Keyboard")

For Each Qfe In QfeSet
    Ret = Qfe.Description
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

キーボードのデバイスIDを取得

'-----------------------------------
'キーボードのデバイスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Keyboard")

For Each Qfe In QfeSet
    Ret = Qfe.DeviceID
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

キーボードのステータスを取得

'-----------------------------------
'キーボードのステータスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Keyboard")

For Each Qfe In QfeSet
    Ret = Qfe.Status
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_PrintJob

プリンタJobの一覧を取得

'-----------------------------------
'プリンタJobの一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_PrintJob")


For Each Qfe In QfeSet
    Ret = Ret & Qfe.DriverName & vbTab & Qfe.JobID & vbTab &Qfe.Document & vbTab & Qfe.Size & vbTab & Qfe.Owner & vbTab & Qfe.JobStatus & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_Printer

インストールされたプリンタの一覧を取得

'-----------------------------------
'インストールされたプリンタの一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Printer")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Caption & vbTab & Qfe.PortName & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

LPT1ポートに割り当てられたプリンタのドライバ名取得

'-----------------------------------
'LPT1ポートに割り当てられたプリンタのドライバ名取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Printer Where PortName='LPT1:'")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.DriverName
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

登録されたネットワークプリンタの一覧を取得(XP以降)

'-----------------------------------
'登録されたネットワークプリンタの一覧を取得(XP以降)
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Printer Where Network=True")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Caption & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プリンタの状態を取得

'-----------------------------------
'プリンタの状態を取得
'
'1 Paused 2 Error 3 Pending Deletion 4 Paper Jam 5 Paper Out
'6 Manual Feed 7 Paper Problem 8 Offline 9 IO Active 10 Busy
'11 Printing 12 Output Bin Full 13 Not Available 14 Waiting 15 Processing
'16 Initialization 17 Warming Up 18 Toner Low 19 No Toner 20 Page Punt
'21 User Intervention Required 22 Out of Memory
'23 Door Open 24 Server_Unknown 25 Power Save 
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Printer")

For Each Qfe In QfeSet
    Ret = Qfe.PrinterState
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

通常使うプリンタを取得(XP以降)

'-----------------------------------
'通常使うプリンタを取得(XP以降)
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Printer Where Default='True'")

For Each Qfe In QfeSet
    Ret = Qfe.Caption & vbTab & Qfe.PortName
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_Process

アプリケーションを起動する

'-----------------------------------
'アプリケーションを起動する
'
'-----------------------------------
Option Explicit

Dim Prc
Dim Locator
Dim Service
Dim Ret
Dim Pid

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set Prc = Service.Get("Win32_Process")

Ret = Prc.Create("notepad.exe", Null, Null, Pid)

If Pid <> 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

起動中のプロセスを参照

'-----------------------------------
'起動中のプロセスを参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Caption & VbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

指定したプログラムのプロセスIDを取得

'-----------------------------------
'指定したプログラムのプロセスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='WINLOGON.EXE'")

For Each Qfe In QfeSet
    Ret = Qfe.ProcessId
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロセス生成日時を取得

'-----------------------------------
'プロセス生成日時を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='WINLOGON.EXE'")

For Each Qfe In QfeSet
    Ret = Qfe.CreationDate
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

親プロセスのプロセスIDを取得

'-----------------------------------
'親プロセスのプロセスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='WINLOGON.EXE'")

For Each Qfe In QfeSet
    Ret = Qfe.ParentProcessId
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロセスの優先度を取得

'-----------------------------------
'プロセスの優先度を取得
'Highest 0 -- Lowest 31
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='WINLOGON.EXE'")

For Each Qfe In QfeSet
    Ret = Qfe.Priority
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロセスの実行可能パスを取得

'-----------------------------------
'プロセスの実行可能パスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='explorer.exe'")

For Each Qfe In QfeSet
    Ret = Qfe.ExecutablePath
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロセスのオーナーユーザーを取得する

'-----------------------------------
'プロセスのオーナーユーザーを取得する
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret
Dim User
Dim Domain

Ret = -1

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='explorer.exe'")

For Each Qfe In QfeSet
    Ret = Qfe.GetOwner(User,Domain)
Next

If Ret = 0 Then
    Wscript.Echo Domain & "\" & User
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロセスオーナーユーザーのセキュリティIDを取得する

'-----------------------------------
'プロセスオーナーユーザーのセキュリティIDを取得する
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret
Dim Sid

Ret = -1

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='explorer.exe'")

For Each Qfe In QfeSet
    Ret = Qfe.GetOwnerSid(Sid)
Next

If Ret = 0 Then
    Wscript.Echo Sid
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロセスの強制終了

'-----------------------------------
'プロセスの強制終了
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='CMD.EXE'")

For Each Qfe In QfeSet
    Qfe.Terminate
Next


Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロセスの優先度を変更する(XP以降)

'-----------------------------------
'プロセスの優先度を変更する(XP以降)
'
'64      idle
'16384   Below Normal
'32      Normal
'32768   Above Normal
'128     HighProprity
'256     Realtime
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Ret = -1

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Process Where Caption='CMD.EXE'")

For Each Qfe In QfeSet
    Ret = Qfe.SetPriority(16384)
Next

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_QuickFixEngineering

適用済みHotfixの一覧

'-----------------------------------
'適用済みHotfixの一覧
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_QuickFixEngineering")

For Each Qfe In QfeSet
    If Qfe.HotfixID <> "File 1" Then
        Ret = Ret & Qfe.HotfixID & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Hotfixの説明を参照

'-----------------------------------
'Hotfixの説明を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_QuickFixEngineering Where HotfixID='Q823718'")

For Each Qfe In QfeSet
        Ret = Qfe.HotfixID & vbTab & Qfe.Description & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Hotfixの適用したユーザー名を参照

'-----------------------------------
'Hotfixの適用したユーザー名を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_QuickFixEngineering Where HotfixID='Q823718'")

For Each Qfe In QfeSet
        Ret = Qfe.HotfixID & vbTab & Qfe.InstalledBy & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_SoftwareFeature

インストールされたソフトウエアの一覧

'-----------------------------------
'インストールされたソフトウエアの一覧
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_SoftwareFeature Where Caption <> Null")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Caption & vbTab & Qfe.Version & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

インストールされたMicrosoft製品の一覧

'-----------------------------------
'インストールされたMicrosoft製品の一覧
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_SoftwareFeature " _
                & "Where Vendor = 'Microsoft Corporation' And Caption <> Null")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Caption & vbTab & Qfe.Version & vbTab & Qfe.Vendor & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_PingStatus

Pingの応答を参照(XP以降)

'-----------------------------------
'Pingの応答を参照(XP以降)
'
'
'0 Success 
'11001 Buffer Too Small 
'11002 Destination Net Unreachable 
'11003 Destination Host Unreachable 
'11004 Destination Protocol Unreachable 
'11005 Destination Port Unreachable 
'11006 No Resources 
'11007 Bad Option 
'11008 Hardware Error 
'11009 Packet Too Big 
'11010 Request Timed Out 
'11011 Bad Request 
'11012 Bad Route 
'11013 TimeToLive Expired Transit 
'11014 TimeToLive Expired Reassembly 
'11015 Parameter Problem 
'11016 Source Quench 
'11017 Option Too Big 
'11018 Bad Destination 
'11032 Negotiating IPSEC 
'11050 General Failure 
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_PingStatus " _
                & "Where Address = '192.168.0.1'")

For Each Qfe In QfeSet
    Ret = Qfe.StatusCode
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CIM_DataFile

ファイルの作成日を取得

'-----------------------------------
'ファイルの作成日を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_DataFile " _
                    & "Where Name = 'c:\\boot.ini'")

For Each Qfe In QfeSet
    Ret = Qfe.InstallDate
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ファイルサイズを取得

'-----------------------------------
'ファイルサイズを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_DataFile " _
                    & "Where Name = 'c:\\boot.ini'")

For Each Qfe In QfeSet
    Ret = Qfe.FileSize
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ファイルのアクセス日を取得

'-----------------------------------
'ファイルのアクセス日を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_DataFile " _
                    & "Where Name = 'c:\\boot.ini'")

For Each Qfe In QfeSet
    Ret = Qfe.LastAccessed
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ファイルの更新日を取得

'-----------------------------------
'ファイルの更新日を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_DataFile " _
                    & "Where Name = 'c:\\boot.ini'")

For Each Qfe In QfeSet
    Ret = Qfe.LastModified
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ショートファイル名を取得

'-----------------------------------
'ショートファイル名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_DataFile " _
                    & "Where Name = 'c:\\boot.ini'")

For Each Qfe In QfeSet
    Ret = Qfe.EightDotThreeFileName
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ファイルの拡張子を取得

'-----------------------------------
'ファイルの拡張子を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_DataFile " _
                    & "Where Name = 'c:\\boot.ini'")

For Each Qfe In QfeSet
    Ret = Qfe.Extension
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ファイルの一覧を取得

'-----------------------------------
'ファイルの一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_DataFile " _
                    & "Where Drive='c:' And Path = '\\'")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Name & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CIM_Directory

フォルダの作成日を取得

'-----------------------------------
'フォルダの作成日を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_Directory " _
                    & "Where Name='c:\\Program Files'")

For Each Qfe In QfeSet
    Ret = Qfe.InstallDate
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

フォルダのアクセス日を取得

'-----------------------------------
'フォルダのアクセス日を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_Directory " _
                    & "Where Name='c:\\Program Files'")

For Each Qfe In QfeSet
    Ret = Qfe.LastAccessed
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

フォルダの更新日を取得

'-----------------------------------
'フォルダの更新日を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_Directory " _
                    & "Where Name='c:\\Program Files'")

For Each Qfe In QfeSet
    Ret = Qfe.LastModified
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

フォルダのショートファイル名を取得

'-----------------------------------
'フォルダのショートファイル名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_Directory " _
                    & "Where Name='c:\\Program Files'")

For Each Qfe In QfeSet
    Ret = Qfe.EightDotThreeFileName
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

フォルダの隠し属性かどうか調べる

'-----------------------------------
'フォルダの隠し属性かどうか調べる
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_Directory " _
                    & "Where Name='c:\\System Volume Information'")

For Each Qfe In QfeSet
    Ret = Qfe.Hidden
Next

Wscript.Echo Ret
Wscript.Quit Abs(Ret)

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

フォルダのシステム属性かどうか調べる

'-----------------------------------
'フォルダのシステム属性かどうか調べる
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From CIM_Directory " _
                    & "Where Name='c:\\System Volume Information'")

For Each Qfe In QfeSet
    Ret = Qfe.System
Next

Wscript.Echo Ret
Wscript.Quit Abs(Ret)

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_LogicalDisk

ドライブの一覧を取得

'-----------------------------------
'ドライブの一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_LogicalDisk")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Name & vbTab & Qfe.VolumeName & vbTab & Qfe.FileSystem & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ドライブの種類を取得

'-----------------------------------
'ドライブの種類を取得
'0 Unknown 
'1 No Root Directory 
'2 Removable Disk 
'3 Local Disk 
'4 Network Drive 
'5 Compact Disc 
'6 RAM Disk 
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_LogicalDisk Where Name='C:'")

For Each Qfe In QfeSet
    Ret = Qfe.DriveType
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ドライブのファイルシステムを取得

'-----------------------------------
'ドライブのファイルシステムを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_LogicalDisk Where Name='C:'")

For Each Qfe In QfeSet
    Ret = Qfe.FileSystem
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ドライブの空き容量を取得

'-----------------------------------
'ドライブの空き容量を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_LogicalDisk Where Name='C:'")

For Each Qfe In QfeSet
    Ret = Qfe.FreeSpace
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ドライブのサイズを取得

'-----------------------------------
'ドライブのサイズを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_LogicalDisk Where Name='C:'")

For Each Qfe In QfeSet
    Ret = Qfe.Size
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ディスククォータの有効・無効を取得

'-----------------------------------
'ディスククォータの有効・無効を取得
'XP以降
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_LogicalDisk Where Name='C:'")

For Each Qfe In QfeSet
    Ret = Qfe.SupportsDiskQuotas
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ドライブのボリューム名を取得

'-----------------------------------
'ドライブのボリューム名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_LogicalDisk Where Name='C:'")

For Each Qfe In QfeSet
    Ret = Qfe.VolumeName
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ドライブのボリュームシリアルナンバーを取得

'-----------------------------------
'ドライブのボリュームシリアルナンバーを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_LogicalDisk Where Name='C:'")

For Each Qfe In QfeSet
    Ret = Qfe.VolumeSerialNumber
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

次回起動時にChkDskを実行(XP以降)

'-----------------------------------
'次回起動時にChkDskを実行(XP以降)
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_LogicalDisk Where Name='C:'")

For Each Qfe In QfeSet
    Ret = Qfe.ExcludeFromAutochk()
Next

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_DiskDrive

HDDのセクタあたりのバイト数を取得

'-----------------------------------
'HDDのセクタあたりのバイト数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.BytesPerSector
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

HDDの型式を取得

'-----------------------------------
'HDDの型式を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.Caption
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

HDDインターフェイス(IDE,SCSI,etc)を参照

'-----------------------------------
'HDDインターフェイス(IDE,SCSI,etc)を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.InterfaceType
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ディスクの種類を参照

'-----------------------------------
'ディスクの種類を参照
'"Removable media","Fixed hard disk","Unknown"
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.MediaType
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ディスクのPlug&PlayIDを参照

'-----------------------------------
'ディスクのPlug&PlayIDを参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.PNPDeviceID
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

SCSIディスクのバスIDを取得

'-----------------------------------
'SCSIディスクのバスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.SCSIBus
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

SCSIディスクのLUNを取得

'-----------------------------------
'SCSIディスクのLUNを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.SCSILogicalUnit
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ディスクサイズを取得

'-----------------------------------
'ディスクサイズを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.Size
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ディスクステータスを参照

'-----------------------------------
'ディスクステータスを参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.Status
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ディスクシリンダ数を取得

'-----------------------------------
'ディスクシリンダ数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.TotalCylinders
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ディスクヘッダ数を取得

'-----------------------------------
'ディスクヘッダ数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.TotalHeads
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ディスクセクタ数を取得

'-----------------------------------
'ディスクセクタ数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.TotalSectors
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ディスクトラック数を取得

'-----------------------------------
'ディスクトラック数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.TotalTracks
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

トラックあたりのシリンダ数を取得

'-----------------------------------
'トラックあたりのシリンダ数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive")

For Each Qfe In QfeSet
    Ret = Qfe.TracksPerCylinder
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

2台目HDDのドライブのxxを参照

'-----------------------------------
'2台目HDDのドライブのxxを参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_DiskDrive Where Index='1'")

For Each Qfe In QfeSet
    Ret = Qfe.Caption
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_NTLogEvent

システムイベントのエラーログを抽出

'-----------------------------------
'システムイベントのエラーログを抽出
'
'EventType
'1 Error 
'2 Warning 
'3 Information 
'4 Security audit success 
'5 Security audit failure 
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NTLogEvent Where Logfile='System' And EventType='1'")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Message & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

指定日時以降のアプリケーションログを抽出

'-----------------------------------
'指定日時以降のアプリケーションログを抽出
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NTLogEvent " _
        & "Where Logfile='Application' And TimeGenerated > '2004/06/01'")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Message & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

レコードナンバーとイベントコードを指定してログを抽出

'-----------------------------------
'レコードナンバーとイベントコードを指定してログを抽出
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NTLogEvent " _
        & "Where RecordNumber<'100' And EventCode='1704'")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.RecordNumber & vbTab & Qfe.TimeGenerated & vbTab & Qfe.Message & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ソースネームを指定してログを抽出

'-----------------------------------
'ソースネームを指定してログを抽出
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NTLogEvent Where SourceName='MsiInstaller'")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Type & vbTab & Qfe.Message & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_Service

サービス一覧を取得

'-----------------------------------
'サービス一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Service")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Caption & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

稼動中のサービス一覧を取得

'-----------------------------------
'稼動中のサービス一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Service Where Started='True'")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Name & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サービスのプロセスIDを取得

'-----------------------------------
'サービスのプロセスIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Service Where Name='Messenger'")

For Each Qfe In QfeSet
    Ret = Qfe.ProcessId & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サービスの種類を取得

'-----------------------------------
'サービスの種類を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Service Where Name='Messenger'")

For Each Qfe In QfeSet
    Ret = Qfe.ServiceType & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サービスの開始状態を取得

'-----------------------------------
'サービスの開始状態を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Service Where Name='Messenger'")

For Each Qfe In QfeSet
    Ret = Qfe.Started & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サービスの開始モードを取得

'-----------------------------------
'サービスの開始モードを取得
'Boot,System,Auto,Manual,Disabled
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Service Where Name='Messenger'")

For Each Qfe In QfeSet
    Ret = Qfe.StartMode & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サービスの開始する

'-----------------------------------
'サービスの開始する
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Service Where Name='Messenger'")

For Each Qfe In QfeSet
    Qfe.StartService()
Next

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サービスの停止する

'-----------------------------------
'サービスの停止する
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Service Where Name='Messenger'")

For Each Qfe In QfeSet
    Qfe.StopService()
Next

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サービスの開始モードを変更する

'-----------------------------------
'サービスの開始モードを変更する
'Boot,System,Automatic,Manual,Disabled
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Service Where Name='Messenger'")

For Each Qfe In QfeSet
    Qfe.ChangeStartMode("Disabled")
Next

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_SystemAccount

システムアカウントの一覧を取得

'-----------------------------------
'システムアカウントの一覧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_SystemAccount")

For Each Qfe In QfeSet
    Ret = Ret & Qfe.Name & vbTab & Qfe.Domain & vbTab & Qfe.SID & vbTab & Qfe.Description & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_WindowsProductActivation

アクティベーションの状態を取得

'-----------------------------------
'アクティベーションの状態を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_WindowsProductActivation")

For Each Qfe In QfeSet
    Ret = Qfe.ActivationRequired
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

プロダクトキーを取得

'-----------------------------------
'プロダクトキーを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_WindowsProductActivation")

For Each Qfe In QfeSet
    Ret = Qfe.ProductID
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_BaseBoard

マザーボードの製造元を取得

'-----------------------------------
'マザーボードの製造元を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_BaseBoard")

For Each Qfe In QfeSet
    Ret = Qfe.Manufacturer & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

マザーボードの型式を取得

'-----------------------------------
'マザーボードの型式を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_BaseBoard")

For Each Qfe In QfeSet
    Ret = Qfe.Product & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

マザーボードのバージョンを取得

'-----------------------------------
'マザーボードのバージョンを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_BaseBoard")

For Each Qfe In QfeSet
    Ret = Qfe.Version & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_Processor

CPUのモデル・ステップを参照

'-----------------------------------
'CPUのモデル・ステップを参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.Description & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUの名前を取得

'-----------------------------------
'CPUの名前を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.Name & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUの製造元を取得

'-----------------------------------
'CPUの製造元を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.Manufacturer & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUアーキテクチャを参照

'-----------------------------------
'CPUアーキテクチャを参照
'
'0 x86 
'1 MIPS 
'2 Alpha 
'3 PowerPC 
'6 ia64 
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.Architecture & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUの現在の周波数を取得

'-----------------------------------
'CPUの現在の周波数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.CurrentClockSpeed & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUの現在の電圧を取得

'-----------------------------------
'CPUの現在の電圧を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.CurrentVoltage & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUファミリーを取得

'-----------------------------------
'CPUファミリーを取得
'
'1 Other 
'2 Unknown 
'13 PentiumR II 
'14 PentiumR processor with MMX technology 
'15 Celeron? 
'16 PentiumR II Xeon 
'17 PentiumR III 
'26 K6-2 
'27 K6-3 
'28 AMD Athlon? Processor Family 
'29 AMDR Duron? Processor 
'30 AMD2900 Family 
'31 K6-2+ 
'130 Itanium? Processor 
'176 PentiumR III Xeon? 
'177 PentiumR III Processor with IntelR SpeedStep? Technology 
'178 PentiumR 4 
'179 IntelR Xeon? 
'180 AS400 Family 
'181 IntelR Xeon? processor MP 
'182 AMD AthlonXP? Family 
'183 AMD AthlonMP? Family 
'184 IntelR ItaniumR 2 
'185 AMD Opteron? Family 
'190 K7 
'http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_processor.asp
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.Family & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUバスクロックを取得

'-----------------------------------
'CPUバスクロックを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.ExtClock & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPU最大周波数を取得

'-----------------------------------
'CPU最大周波数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.MaxClockSpeed & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUキャッシュサイズを取得

'-----------------------------------
'CPUキャッシュサイズを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.L2CacheSize & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUIDを取得

'-----------------------------------
'CPUIDを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.ProcessorId & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUレヴィジョンを取得

'-----------------------------------
'CPUレヴィジョンを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.Revision & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ソケットタイプを取得

'-----------------------------------
'ソケットタイプを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.SocketDesignation  & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUステップを取得

'-----------------------------------
'CPUステップを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.Stepping  & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUユニークID(PIII)を取得

'-----------------------------------
'CPUユニークID(PIII)を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.UniqueId  & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

CPUバージョンを取得

'-----------------------------------
'CPUバージョンを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_Processor")

For Each Qfe In QfeSet
    Ret = Qfe.Version & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_BIOS

BIOS名の取得

'-----------------------------------
'BIOS名の取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_BIOS")

For Each Qfe In QfeSet
    Ret = Qfe.Name & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

BIOS製造元の取得

'-----------------------------------
'BIOS製造元の取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_BIOS")

For Each Qfe In QfeSet
    Ret = Qfe.Manufacturer & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

BIOSリリース日の取得

'-----------------------------------
'BIOSリリース日の取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_BIOS")

For Each Qfe In QfeSet
    Ret = Qfe.ReleaseDate & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

BIOSシリアルナンバーの取得

'-----------------------------------
'BIOSシリアルナンバーの取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_BIOS")

For Each Qfe In QfeSet
    Ret = Qfe.SerialNumber & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_OperatingSystem

ブートパーティションを取得

'-----------------------------------
'ブートパーティションを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.BootDevice & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

OSのビルドナンバーを取得

'-----------------------------------
'OSのビルドナンバーを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.BuildNumber & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

OSのビルドタイプを取得

'-----------------------------------
'OSのビルドタイプを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.BuildType & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

OS名を取得

'-----------------------------------
'OS名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Caption & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

OS標準の文字コードセットを取得

'-----------------------------------
'OS標準の文字コードセットを取得
'
'
'437 IBM PC
'932 Shift JIS
'1252 Windows ANSI
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.CodeSet & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サービスパックの種類を取得

'-----------------------------------
'サービスパックの種類を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.CSDVersion & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

コンピュータ名を参照

'-----------------------------------
'コンピュータ名を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.CSName & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

タイムゾーン設定を参照

'-----------------------------------
'タイムゾーン設定を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.CurrentTimeZone & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

空き物理メモリを取得

'-----------------------------------
'空き物理メモリを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.FreePhysicalMemory & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

空きスワップ容量を参照

'-----------------------------------
'空きスワップ容量を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.FreeSpaceInPagingFiles & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

空き仮想メモリを参照

'-----------------------------------
'空き仮想メモリを参照
'(空き物理メモリ+空きスワップ容量)
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.FreeVirtualMemory & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

OSインストール日時を参照

'-----------------------------------
'OSインストール日時を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.InstallDate & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

システムロケールの参照

'-----------------------------------
'システムロケールの参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Locale & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

OS名とWindowsディレクトリを参照

'-----------------------------------
'OS名とWindowsディレクトリを参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Name & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

実行プロセス数を取得

'-----------------------------------
'実行プロセス数を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.NumberOfProcesses & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ライセンス許諾組織名を取得

'-----------------------------------
'ライセンス許諾組織名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Organization & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

OSの種類を取得

'-----------------------------------
'OSの種類を取得
'
'
'0 = Unknown
'1 = Other
'13 = JavaVM
'14 = MSDOS
'15 = WIN3x
'16 = WIN95
'17 = WIN98
'18 = WINNT,WIN2K
'19 = WINCE
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.OSType & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ライセンス許諾ユーザー名を取得

'-----------------------------------
'ライセンス許諾ユーザー名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.RegisteredUser & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

シリアルキーを取得

'-----------------------------------
'シリアルキーを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.SerialNumber & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

サービスパックバージョンを取得

'-----------------------------------
'サービスパックバージョンを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.ServicePackMajorVersion &  "." & Qfe.ServicePackMinorVersion & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

システムパーティションの取得

'-----------------------------------
'システムパーティションの取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.SystemDevice & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

システムディレクトリの取得

'-----------------------------------
'システムディレクトリの取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.SystemDirectory & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

OSバージョンの取得

'-----------------------------------
'OSバージョンの取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Version & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Windowsディレクトリの取得

'-----------------------------------
'Windowsディレクトリの取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Ret = Qfe.WindowsDirectory & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

PCをシャットダウン

'-----------------------------------
'PCをシャットダウン
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Qfe.Win32Shutdown 1
Next


Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

PCをログオフ

'-----------------------------------
'PCをログオフ
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Qfe.Win32Shutdown 0
Next


Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

PCを再起動

'-----------------------------------
'PCを再起動
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Qfe.Win32Shutdown 2
Next


Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

PCを電源断

'-----------------------------------
'PCを電源断
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_OperatingSystem")

For Each Qfe In QfeSet
    Qfe.Win32Shutdown 8
Next


Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_ComputerSystem

Adminパスワードの状態を取得

'-----------------------------------
'Adminパスワードの状態を取得
'
'1 Disabled
'2 Enabled
'3 Not Implemented
'4 Unknown
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.AdminPasswordStatus & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

コンピュータ名を取得

'-----------------------------------
'コンピュータ名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Name & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ドメイン名またはワークグループ名を取得

'-----------------------------------
'ドメイン名またはワークグループ名を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Domain & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

コンピュータの役割を参照

'-----------------------------------
'コンピュータの役割を参照
'
'0 Standalone Workstation
'1 Member Workstation
'2 Standalone Server
'3 Member Server
'4 Backup Domain Controller
'5 Primary Domain Controller
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.DomainRole & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

赤外線デバイスのサポート

'-----------------------------------
'赤外線デバイスのサポート
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.InfraredSupported & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

製造元の参照

'-----------------------------------
'製造元の参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Manufacturer & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

PCモデル名の参照

'-----------------------------------
'PCモデル名の参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Model & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

搭載CPU数を参照

'-----------------------------------
'搭載CPU数を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.NumberOfProcessors & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

OEM infomationを参照

'-----------------------------------
'OEM infomationを参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.OEMStringArray & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ライセンス許諾ユーザー名を参照

'-----------------------------------
'ライセンス許諾ユーザー名を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.PrimaryOwnerName & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

物理メモリを参照

'-----------------------------------
'物理メモリを参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.TotalPhysicalMemory & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ログオンユーザーを参照

'-----------------------------------
'ログオンユーザーを参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.UserName & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

電源ONの種類を参照

'-----------------------------------
'電源ONの種類を参照
'
'Event that causes the system to power up.
'0 Reserved
'1 Other
'2 Unknown
'3 APM Timer
'4 Modem Ring
'5 LAN Remote
'6 Power Switch
'7 PCI PME#
'8 AC Power Restored
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.WakeUpType & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ワークグループ(XP,2003)を参照

'-----------------------------------
'ワークグループ(XP,2003)を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Workgroup & vbCrLf
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

コンピュータ名の変更

'-----------------------------------
'コンピュータ名の変更
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_ComputerSystem")

For Each Qfe In QfeSet
    Ret = Qfe.Rename("NewName")
Next

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Win32_NetworkAdapterConfiguration

DNSHostNameの取得

'-----------------------------------
'DNSHostNameを取得
'
'Win2K以降、コンピュータ名とHostNameは原則同じ値になる。
'
'ただしコンピュータ名は全部大文字に変換され
'HostNameは大文字小文字の区別を保持するので注意。
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.DNSHostName & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

IP Addressの取得

'-----------------------------------
'IP Addressを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.IPAddress(0) & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

SubNetmaskの取得

'-----------------------------------
'SubNetmaskを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.IPSubnet(0) & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

Gateway1の取得

'-----------------------------------
'DefaultGateway1を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.DefaultIPGateway(0) & vbCrLf
        '2番目のGatewayの値の取得
        'Ret = Qfe.DefaultIPGateway(1) & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

DNSサーバ1の取得

'-----------------------------------
'DNSServer1のアドレスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.DNSServerSearchOrder(0) & vbCrLf
        '2番目のDNSサーバを取得
        'Ret = Qfe.DNSServerSearchOrder(1) & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

WINSサーバ1の取得

'-----------------------------------
'WINSServer1のアドレスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.WINSPrimaryServer & vbCrLf
        '2番目のWINSサーバを取得
        'Ret = Qfe.WINSSecondaryServer & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

DHCPの状態取得

'-----------------------------------
'DHCPの状態を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.DHCPEnabled & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

DHCPサーバアドレスの取得

'-----------------------------------
'DHCPサーバーのアドレスを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.DHCPServer & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

DHCPリース開始時間の取得

'-----------------------------------
'DHCPリース開始時間を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.DHCPLeaseObtained & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

DHCPリース終了時間の取得

'-----------------------------------
'DHCPリース終了時間を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.DHCPLeaseExpires & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

MAC Addressの取得

'-----------------------------------
'MACAddressを取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.MACAddress & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

NetBios Over TCP/IPの有効・無効

'-----------------------------------
'NetBIOS over TCP/IPの設定を取得
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.TcpipNetbiosOptions & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

LMHOSTの有効・無効

'-----------------------------------
'LMHOSTの有効・無効を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.WINSEnableLMHostsLookup & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

ポート制限の有効無効

'-----------------------------------
'TCP/IPフィルタリングの有効・無効を参照
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")

For Each Qfe In QfeSet
    If Qfe.IPEnabled = True Then
        Ret = Qfe.IPFilterSecurityEnabled & vbCrLf
    End If
Next

Wscript.Echo Ret

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

静的アドレスのNICをDHCPにする

'-----------------------------------
'静的アドレスのNICをDHCPにする
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration " _
            & "Where DHCPEnabled=False")

For Each Qfe In QfeSet
    Ret = Qfe.EnableDHCP()
Next

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing

IPアドレスを再取得する

'-----------------------------------
'IPアドレスを再取得する
'
'-----------------------------------
Option Explicit

Dim QfeSet
Dim Qfe
Dim Locator
Dim Service
Dim Ret

Ret = -1

Set Locator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer
Set QfeSet = Service.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where DHCPEnabled = True")

For Each Qfe In QfeSet
    Ret = Qfe.RenewDHCPLease()
Next

If Ret = 0 Then
    Wscript.Echo "OK"
    Wscript.Quit 0
Else
    Wscript.Echo "NG"
    Wscript.Quit 1
End If

Set QfeSet = Nothing
Set Qfe = Nothing
Set Service = Nothing
Set Locator = Nothing