我有关于杀戮过程的问题。下面是我的VB语言代码。我似乎不能杀死ping.exe和conhost.exe,即使创建了70个命令,我也只能杀死1个cmd.exe。谢谢
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim xl As Integer = 368
Dim value As Integer = 0
For value = 0 To 69
Proc.StartInfo = New ProcessStartInfo("C:\Windows\System32\cmd.exe")
Proc.StartInfo.Arguments = ("cmd.exe /k" + TextBox1.Text + " " + ipAdd.Text + " " + TextBox2.Text + " " + TextBox3.Text)
Proc.StartInfo.RedirectStandardInput = True
Proc.StartInfo.RedirectStandardOutput = False
Proc.StartInfo.UseShellExecute = False
Proc.StartInfo.CreateNoWindow = True
Proc.Start()
Next
Timer1.Enabled = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Proc.Kill()
Proc.Close()
'Proc.Start("cmd.exe", "/C choice /C Y /N /T 3 & Del " + Application.ExecutablePath)
'Application.Exit()
End Sub发布于 2015-08-05 14:57:36
如果您确信要杀死所有cmd进程,您可以尝试:
For Each proc As Process In Process.GetProcessesByName("cmd")
proc.Kill()
Next上面代码的问题是Proc只引用在For Next循环中创建的最后一个流程实例。
https://stackoverflow.com/questions/31821908
复制相似问题