我正在尝试构建一个启动的脚本,然后停止一个进程:
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
时结束此过程。有没有相对简单的方法来做到这一点?
答案 0 :(得分: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