Stop A Running Program

runlp586

New member
Joined
Jan 9, 2007
Messages
1
Programming Experience
5-10
Upon startup, two programs (cpr.exe and cprcore.exe) are launched on our office computers. These programs enhance network access; however, one program (lm7et.exe) will crash if cpr.exe and cprcore.exe are running.

So, I've made a loader that launches lm7et.exe. Upon lm7et.exe closing, then the program starts cpr.exe and cprcore.exe.

1. Stop cpr.exe and cprcore.exe
2. Start lm7et.exe
3. Wait for lm7et.exe to terminate...
4. Start cpr.exe and cprcore.exe

What I need to know is #1 (how to stop cpr.exe and cprcore.exe).

I know it's got to be very easy, but I just can't seem to figure it out for the life of me.

Peace,
runlp586
 
VB.NET:
For Each proc As Process In Process.GetProcesses
    If proc.ProcessName = "cpr" Or proc.ProcessName = "cprcore" Then
        proc.Kill()
    End If
Next
 
Hi ,

If "cpr" and "crpcore" are windows services then we can start or stop the process using the below code

VB.NET:
Imports System.ServiceProcess
 
Private Sub Stop_Processes()
          Dim myController As ServiceController
          For Each myController In System.ServiceProcess.ServiceController.GetServices(".")
                    If myController.ServiceName = "cpr" Or myController.ServiceName = "cprcore" Then
                              myController.Stop()
                    End If
          Next
End Sub
 
Private Sub Start_Processes()
          Dim myController As ServiceController
          For Each myController In System.ServiceProcess.ServiceController.GetServices(".")
                    If myController.ServiceName = "cpr" Or myController.ServiceName = "cprcore" Then
                              myController.Start()
                    End If
          Next
End Sub
 
Back
Top