WMI Fun !! 〜 WMI に興味がある方・システム管理者は必見です! 〜 |
|
![]() |
WMI Fun !! > WMI Sample (VBS) > プリンタのステータスを取得する |
Panasonic Let'snote を長年愛用しています、その理由は My Let'snote で…
中古車買うならやっぱり IT 関連情報を気軽に知りたい方へ、 プリンタのステータスを取得する: Win32_Printer - WMI Sample (VBS)Topics
プリンタのステータスを取得するサンプルプログラムです。
Sample Code
Option Explicit
'WMIにて使用する各種オブジェクトを定義・生成する。 Dim oClassSet Dim oClass Dim oLocator Dim oService Dim sMesStr Dim sStat sStat = Array("Other", "Unknown", "Idle", "Printing", "Warmup", "Stopped printing", "Offline") 'ローカルコンピュータに接続する。 Set oLocator = WScript.CreateObject("WbemScripting.SWbemLocator") Set oService = oLocator.ConnectServer 'クエリー条件を WQL にて指定する。 Set oClassSet = oService.ExecQuery("Select * From Win32_Printer") 'コレクションを解析する。 For Each oClass In oClassSet sMesStr = sMesStr & "プリンタ名: " & oClass.Name & vbCrLf & _ "ステータス: " & sStat(oClass.PrinterStatus - 1) & vbCrLf & vbCrLf Next MsgBox "プリンタのステータスに関する情報です。" & vbCrLf & vbCrLf & sMesStr '使用した各種オブジェクトを後片付けする。 Set oClassSet = Nothing Set oClass = Nothing Set oService = Nothing Set oLocator = Nothing
![]() Comment
実行するとプリンタのステータスを表示します。
を紹介しています。 ![]() Latest sample information
最近WMI Sampleへ追加したサンプルのご紹介です。
興味のあるサンプル・クラスがありましたら参考にしてみて下さい。 |
ご意見・ご要望・ご感想をこちらのアンケートからお待ちしています |
∧ ページの先頭へ… |