Solved

Kill a running process

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

695 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