VBAで指定のアプリ(*.exe)が立ち上がってるかのチェック

Win32_Process クラスを使う。

'指定のプロセスがいたらTrue いないならFalse
Function CheckProcess(aExename) As Boolean

    'WMIにて使用する各種オブジェクトを定義・生成する。
    Dim oClassSet
    Dim oClass
    Dim oLocator
    Dim oService
    Dim sMesStr
    
    'ローカルコンピュータに接続する。
    Set oLocator = CreateObject("WbemScripting.SWbemLocator")
    Set oService = oLocator.ConnectServer
    'クエリー条件をWQLにて指定する。
    Set oClassSet = oService.ExecQuery("Select * From Win32_Process")
    
    'コレクションを解析する。
    For Each oClass In oClassSet
    
        If aExename = oClass.Description Then
            CheckProcess = True
            '使用した各種オブジェクトを後片付けする。
            Set oClassSet = Nothing
            Set oClass = Nothing
            Set oService = Nothing
            Set oLocator = Nothing
            Exit Function
        End If
    
    Next
    
    CheckProcess = False
    
    '使用した各種オブジェクトを後片付けする。
    Set oClassSet = Nothing
    Set oClass = Nothing
    Set oService = Nothing
    Set oLocator = Nothing

End Function


ネタ元