i want to insert all processes that running into listbox,
and also how to "kill" process and start process?
for i = 0 to procCount
...
next i
the list + kill:
For Each p As Process In Process.GetProcesses
ListBox1.Items.Add(p.ProcessName.ToString)
If String.compare(p.ProcessName, "iexplore",true) = 0 Then
p.Kill()
End If
Next
use the kill() to kill process
to open process:
Process.Start("pname.exe")
You can also create a list with all running processes of Excel before starting Excel programatically (using Linq statement):
Dim lstExcelProcess As List(Of Process) = (From p As Process In Process.GetProcesses Where p.ProcessName.ToUpper Like "Excel*".ToUpper).ToList
And after you finished what you had to do, kill the only process that was not listed before:
Dim process As Process = (From p As Process In process.GetProcesses Where p.ProcessName.ToUpper Like "Excel*".ToUpper And Not lstExcelProcess.Contains(p))(0)
process.Kill()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With