Kill Process

azebiak

New member
Joined
Feb 20, 2004
Messages
2
OK, I am using vb.net and I have a question regarding the process killing. I was wondering how you kill a process that is curently selected in a listbox. I tried using a list box called lstProcess and
dim Proc as process
Proc = lstProcess.SelectedItem
Kill.Proc
the listbox contains all the currently running process. This did not work and I was wondering how you would approach this. Thanks
 
You would have to convert the selected item from the listbox to a string and then get that process into your variable using the GetProcessesByName shared method of the process class. The method returns an array so the first member of the array should be good to use.
Code:
Dim proc As Process = Process.GetProcessesByName(Convert.ToString(lstProc.SelectedItem))(0)
proc.Kill()
 
Back
Top