VB.net 关闭进程


程序代码:

    Private Sub KillProcess(processName As String)
        Dim myproc As New System.Diagnostics.Process()
        '得到所有打开的进程   
        Try
            For Each thisproc As Process In Process.GetProcessesByName(processName)
                '找到程序进程,kill之。
                If Not thisproc.CloseMainWindow() Then
                    thisproc.Kill()
                End If
            Next
        Catch Exc As Exception
            MessageBox.Show(Exc.Message)
        End Try
    End Sub

    Public Shared Sub StopProcess(processName As String)
        Try
            Dim ps As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName(processName)
            For Each p As System.Diagnostics.Process In ps
                p.Kill()
            Next
        Catch ex As Exception
            Throw ex
        End Try
    End Sub




Autodesk.AutoCAD.Windows.ContextMenuExtension



欢迎关注微信公众账号ByCAD