CodeItBetter Programming Another VB Programming Blog

How to make sure whether an exe is running already or not

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
'System & API - How to make sure whether an exe is running already or not
Private Sub Main()
    Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE")
    Debug.Print IsProcessRunning("C:\Program Files\Microsoft Visual Studio\VB98\NotRunning.EXE")
End Sub
 
Private Function IsProcessRunning(ByVal sPath As String) As Boolean
    On Error Resume Next
    IsProcessRunning = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_Process " & _
        "WHERE ExecutablePath = '" & Replace(sPath, "\", "\\") & "'").Count
End Function
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.