How to make Application close if program found.
Hey im wondering how can i make vb 2010 application close if program is found i mean like i want to do like this: Waiting for notepad.. .. Notepad found and then program closes!
Sub CloseIfFound(ByVal ProcessName As String)
Dim P = Process.GetProcessesByName(ProcessName)
If P.Length = 0 Then Return
Application.Exit()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
CloseIfFound("notepad")
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim P = Process.GetProcessesByName("notepad")
If P.Length = 0 Then Return
Application.Exit()
End Sub
Private Shared ReadOnly m_BlacklistApplications As New List(Of String)() From { _
"notepad", _
"calc" _
}
If procs.Intersect(m_BlacklistApplications).Any() Then
Application.Exit()
End If
Private Sub Check()
Dim active As Boolean = False
Dim proc() As Process
Do Until active = True
proc = Process.GetProcessesByName("notepad")
If proc.Count > 0 Then active = True
Loop
End
End Sub