{"id":2997,"date":"2004-10-28T07:56:00","date_gmt":"2004-10-27T21:56:00","guid":{"rendered":"http:\/\/new.radio-active.net.au\/web3\/killing-a-process-in-vb-net\/"},"modified":"2014-10-10T13:13:00","modified_gmt":"2014-10-10T02:13:00","slug":"killing-a-process-in-vb-net","status":"publish","type":"post","link":"http:\/\/www.radio-active.net.au\/web3\/2997","title":{"rendered":"Killing a process in VB.NET"},"content":{"rendered":"<p>I spent some time today searching form information on how to kill a process using VB.NET. I was surprised that this was harder than I thought it would be. Mainly because the information does not seem to be documented very well.<\/p>\n<p>Eventually I found some minor links which suggested some help words for searching in the VB.NET help file. There is a data type called PROCESS which can hold information about processes. In a networked environment you can play with processes on other computers. Since I am dealing with a local machine, things are easier.<\/p>\n<p>The code works by getting all the processes on the local machine into an array, and then checking each of them to see if the process name is what we want. If it is we KILL the process.<\/p>\n<p>Normally you would not use KILL since it does not shut things down properly. In my case I do not care since I know that there is an issue because I have already attempted to kill off the process by stopping the service.<\/p>\n<p>So here is the code.<\/p>\n<p>    Dim local As Process() = Process.GetProcesses<br \/>\n<br \/>    Dim i As Integer<br \/>\n<br \/>    For i = 0 To local.Length &#8211; 1<br \/>\n<br \/>      Debug.WriteLine(local(i).ProcessName)<br \/>\n<br \/>      If Strings.UCase(local(i).ProcessName) = Strings.UCase(&#8220;ProcessName&#8221;) Then<br \/>\n<br \/>        local(i).Kill()<br \/>\n<br \/>        TextBox1.Text = &#8220;Found process and Killed Process&#8221;<br \/>\n<br \/>      End If<br \/>\n<br \/>    Next<br \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I spent some time today searching form information on how to kill a process using VB.NET. I was surprised that this was harder than I thought it would be. Mainly because the information does not seem to be documented very &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"http:\/\/www.radio-active.net.au\/web3\/2997\"> <span class=\"screen-reader-text\">Killing a process in VB.NET<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5cfmK-Ml","_links":{"self":[{"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/posts\/2997"}],"collection":[{"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/comments?post=2997"}],"version-history":[{"count":0,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/posts\/2997\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/media?parent=2997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/categories?post=2997"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.radio-active.net.au\/web3\/wp-json\/wp\/v2\/tags?post=2997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}