VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 340,150 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 3,860 people online right now. Registration is fast and FREE... Join Now!




Kill an unwanted process

Loops through the processes and kills a process if it is not wanted

Submitted By: RodgerB
Actions:
Rating:
Views: 6,734

Language: VB.NET

Last Modified: December 11, 2007
Instructions:
1) Copy and paste the subroutine into a class.
2) Read how to call the subroutine.

Snippet


  1. ''' <summary>
  2. ''' Loops through the processes and kills a process if it is not wanted.
  3. ''' </summary>
  4. ''' <param name="strProcessToKill">The process you want killed.</param>
  5. ''' <remarks></remarks>
  6.  
  7. Public Sub killProcess(ByRef strProcessToKill As String)
  8.     Dim proc() As Process = Process.GetProcesses
  9.     For i As Integer = 0 To proc.GetUpperBound(0)
  10.         If proc(i).ProcessName = strProcessToKill Then
  11.             proc(i).Kill()
  12.         End If
  13.     Next
  14. End Sub
  15.  
  16. ' Example Usage.
  17. killProcess("notepad")

Copy & Paste


Comments

chiefofgxbxl 2009-08-08 21:57:37

nice code, works very nice.


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month