'#================================================================================ '#【機能】プロセス一覧を表示 '# '#【補足】 '# ・cscript.exeで実行しないと表示がポップアップされて面倒ですよ '# '#【制約】 '# ・ '# '#【改訂履歴】 '# 2010/05/15 : 新規 : '#================================================================================ Option Explicit ' 変数宣言 Dim objWShell ' Object(シェル) Dim objFileSys ' Object(ファイル) Dim objWMIServ ' Object(WMIサービス) Dim objProcess ' Object(プロセス) Dim objProList ' Object(プロセス一覧) Dim hostname ' ホスト名 Dim cmd ' 実行コマンド Dim num ' 件数 Dim ret ' (作業変数) 戻り値 ' 事前確認 IF InStr(LCase(WScript.FullName), "cscript.exe") <= 0 Then '(cscript.exe起動でない時) MsgBox "cscript.exe で実行してください。" & vbCrLf & "そうしないと、表示がゴチャっとします。" WScript.Quit(1) ' 終了 End If ' 初期設定 Set objWShell = CreateObject("WScript.Shell") Set objFileSys = CreateObject("Scripting.FileSystemObject") Set objWMIServ = GetObject("winmgmts:{impersonationLevel=impersonate}") ' 検索条件を設定(CommandLine) '##Set objProList = objWMIServ.ExecQuery("select * from Win32_Process where Name='xxxxx.exe' And CommandLine like '" & cmd & "'") Set objProList = objWMIServ.ExecQuery("select * from Win32_Process") For Each objProcess In objProList WScript.Echo objProcess.CommandLine Next ' 後始末 Set objWShell = Nothing Set objFileSys = Nothing Set objWMIServ = Nothing Set objProcess = Nothing Set objProList = Nothing ' 終了 WScript.Quit(0)