VB.NET結束程序
'Imports System.Diagnostics
Dim
ps
As
Process() = Process.GetProcessesByName(
"notepad"
)
For
Each
p
As
Process
In
ps
p.Kill()
Next
Public Sub Main()
If ProcessOnN("MyPro") > 0 Then
KillProcess("MyPro")
End If
End Sub
Public Function ProcessOnN(ByVal ProcessName As String) As Integer
Dim s As String = ProcessName.ToUpper.Replace(".EXE", "").Trim
Return Process.GetProcessesByName(s).Length
End Function
Public Sub KillProcess(ByVal comObjProcessName As String)
Dim mProcessList As Process()
mProcessList = Process.GetProcessesByName(comObjProcessName)
For Each tmpProcess As Process In mProcessList
tmpProcess.Kill()
Next
End Sub