WMI Fun !! 〜 WMI に興味がある方・システム管理者は必見です! 〜 |
|
|
WMI Fun !! > WMI Step > VBS(WSH) から WMI のメソッドを使ってみよう |
IT 関連情報を気軽に知りたい方へ、
私も使っていますお勧め SIM フリースマホ ASUS Zenfone VBS(WSH) から WMI のメソッドを使ってみよう - WMI StepTopics
VB での使い方でも紹介していましたが VBS からもメソッドを使うことができます。ここでは VBS での使い方を紹介します。
Sample Code
Option Explicit
Dim oPrcSet Dim oPrc Dim oLocator Dim oService Dim sMesStr Set oLocator = WScript.CreateObject("WbemScripting.SWbemLocator") Set oService = oLocator.ConnectServer Set oPrcSet = oService.ExecQuery _ ("Select * From Win32_Process Where Description=""notepad.exe""") For Each oPrc In oPrcSet oPrc.Terminate MsgBox "PID が " & CStr(oPrc.ProcessId) & " のメモ帳を終了しました。" Next Set oPrcSet = Nothing Set oPrc = Nothing Set oLocator = Nothing Set oService = Nothing
![]() Comment
実行する前にメモ帳を複数起動しておいてください。実行するとメモ帳が次々に終了していきます。 ![]() |
ご意見・ご要望・ご感想をこちらのアンケートからお待ちしています |
∧ ページの先頭へ… |