Solved

Kill a running process

Posted on 2015-01-13
1
147 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now