vs vb.net .vb need help with: Process.GetProcessesByName

vmars316 621 Reputation points
2020-09-11T22:56:01.013+00:00

Hello & Thanks ;
I would like to kill the process "iexplore"
but can't figure out the syntax .

Imports System
Imports System.Diagnostics
Imports System.ComponentModel
.
.
.
        Dim localByName As Process() = Process.GetProcessesByName("iexplore")
        localByName.kill()

Thanks for your Help...

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,860 questions
{count} votes

2 additional answers

Sort by: Most helpful
  1. vmars316 621 Reputation points
    2020-09-12T16:17:02.497+00:00

    Thanks Castorix31 ;
    That works fine as a standalone ,
    but now I want to put it into a MouseUp event .

    Ultimately , I want to stop IE from Running .
    I don't know how to Cancel a WebBrowser1.NewWindow Event
    or even if the timing is right to stop it at this point (perhaps it has already opened IE ) .

    So my thinking is to Catch a MouseUp Event, and just to be sure to Kill() IE .

    But the following code doesn't work , It never gets there ,
    what am I doing wrong ?
    Or should I Post this as a new Issue ?

        Private Sub WebBrowser1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
            MsgBox("We are Here : Sub WebBrowser1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)")
            Dim processArray As Process() = Process.GetProcessesByName("iexplore")
            For Each p As Process In processArray
                p.Kill()
            Next
        End Sub
    

    Thanks


  2. Sheng Jiang 蒋晟 206 Reputation points
    2020-09-12T17:27:01.817+00:00

    You can enumerate the ShellWindows collection to get Internet Explorer instances, then call IWebBrowser2::Quit on each instance.
    See How to connect to a running instance of Internet Explorer.

    The ShellWindows collection also exposes the DShellWindowsEvents event that you can use to monitor window creation.

    Note if you silently kill IE windows and the user actually intent to open IE, the user would try to find what is the culprit and eventually remove your program.

    0 comments No comments