Solved

Kill a running process

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 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