Solved

Kill a running process

Posted on 2015-01-13
1
150 Views
Last Modified: 2015-01-13
I'm trying to kill a process that I've started in the program start-up (so its only running while my application is running), however when I try and terminate the process is still running.

Ive tried closing 3 different ways:-
        phpProcess.Kill()
        phpProcess.CloseMainWindow()
        phpProcess.Close()

Open in new window


However the process is still running after I close the application.

What Ive got soo far is:-
    Dim phpProcess As Process
    Dim startInfo As New ProcessStartInfo

    Private Sub Form1_Leave(sender As Object, e As EventArgs) Handles Me.Leave
        phpProcess.Kill()
        phpProcess.CloseMainWindow()
        phpProcess.Close()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        NotifyIcon1.Visible = True

        Me.Hide()

        NotifyIcon1.BalloonTipText = "Hi from right system tray"
        NotifyIcon1.ShowBalloonTip(500)

        startInfo.FileName = "c:\xampp\php\php.exe"
        startInfo.WorkingDirectory = "u:\Documents\Webapp1"
        startInfo.Arguments = "-S localhost:85"
        startInfo.WindowStyle = ProcessWindowStyle.Hidden

        phpProcess = Process.Start(startInfo)
    End Sub

Open in new window


Does anyone have any pointers?
0
Comment
Question by:tonelm54
1 Comment
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 40547408
Instead of Form_Leave, try Form_Closing event.
Leave may not always fire.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question