0

我正在尝试构建一个启动脚本,然后停止一个进程:

Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Process.Start("C:\batchfile.bat")
    End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
    (DESIRED CODE HERE)
    End Sub
End Class

Button2启动batchfile.bat. 我需要找到一种方法来在Button1单击时结束此过程。有没有相对简单的方法来做到这一点?

4

1 回答 1

1

请检查此示例代码

  Dim p1 As Process
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        p1 = Process.Start("C:\Users\082043\Desktop\akshay.bat")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        p1.Kill()
    End Sub
于 2013-02-21T04:55:18.057 回答