How to check exe is running or not in VB 6.0

If you want to know whether a particular application is running or not, you can identify this using following simple code in vb 6.0.
The following example will determine whether Notepad application is running or not in your system.

Private Sub Command1_Click()
   If isRunningExe("notepad.exe") Then
     MsgBox "exe is in running state"
   End If
End Sub
Private Function isRunningExe(exeName As String) As Boolean
   Dim strQuery As String
   strQuery = "SELECT Name FROM Win32_Process WHERE Name='" & exeName & "'"
   isRunningExe = GetObject("winmgmts:").ExecQuery(strQuery).Count
End Function


One thought on “How to check exe is running or not in VB 6.0”

Comments are closed.