Kill an unwanted process
This subroutine gives the programmer the ability to kill an unwanted process. For example, a student could be playing an inappropriate game. This subroutine will detect the game and destroy the process, thus exiting the game.
VB.NET
''' <summary>
''' Loops through the processes and kills a process if it is not wanted.
''' </summary>
''' <param name="strProcessToKill">The process you want killed.</param>
''' <remarks></remarks>
Public Sub killProcess(ByRef strProcessToKill As String)
Dim proc() As Process = Process.GetProcesses
For i As Integer = 0 To proc.GetUpperBound(0)
If proc(i).ProcessName = strProcessToKill Then
proc(i).Kill()
End If
Next
End Sub
' Example Usage.
killProcess("notepad")
See Also
- </DIC> Submission - http://www.dreamincode.net/code/snippet1523.htm
page revision: 0, last edited: 16 Dec 2007 05:11