Sunday, 22 July 2012

kill and start program in

The following VB.NET program allows starting multiple calculator applications and later it kills the same instances of all calculator applications.

The Process component is a useful tool for starting, stopping, controlling, and monitoring applications. A process is a running application and a thread is the basic unit to which the operating system allocates processor time. Using the Process component, you can obtain a list of the processes that are running, or you can start a new process.

GetProcessesByName(String) - Creates an array of new Process components and associates them with all the process resources on the local computer that share the specified process name.

  Dim _proceses As Process()
  _proceses = Process.GetProcessesByName("calc")

The above syntax retrieve all the process associated with "calc" application in the _proceses array. System.Diagnostics provides access to local and remote processes and enables you to start and stop local system processes.

Download Source CodePrint Source Code
Public Class Form1

                Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                End Sub

                Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

                                Dim _proceses As Process()
                                _proceses = Process.GetProcessesByName("calc")
                                For Each proces As Process In _proceses

                End Sub

End Class

No comments:

Post a Comment