Solved

Kill a running process

Posted on 2015-01-13
1
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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…

734 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