Solved

kill a specific process (IE page) VB.NET 2003

Posted on 2011-02-21
4
1,031 Views
Last Modified: 2012-05-11
Hi Experts,

My app will open apps 'Outlook', 'Notepad', etc... from WINFORM button.

But I want to open IE page with specific URL, but I also want to kill that specific web-page.

System.Diagnostics.Process.Start("IExplore.exe", "http://sample.com/")

'iexplore' is the process, but, if I have more than one IE page open, I don't want to close others.

Thanks,
Roberto
0
Comment
Question by:RobertoFreemano
[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
4 Comments
 
LVL 8

Expert Comment

by:Toxacon
ID: 34946218
Keep track of the Process IDs (PIDs) so you can shut down the right IE process.
0
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 34948561
Sample Code

1. Start notepad
System.Diagnostics.Process.Start("notepad")

2. Start winword
System.Diagnostics.Process.Start("WINWORD")

3. Start excel
System.Diagnostics.Process.Start("Excel")

4. Start ie and parameter
System.Diagnostics.Process.Start("IExplore.exe", "http://vbnetsample.blogspot.com/")

5. Kill It!!
' Kill all notepad process
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("notepad")

For Each p As Process In pProcess
p.Kill()
Next
0
 
LVL 12

Accepted Solution

by:
Hairbrush earned 100 total points
ID: 34950697
Hi, I think the problem with the code sample given by kalpesh is that it will kill the whole of IE?

I have tried the following code sample, and it works.  You will need to add a reference to the COM object c:\windows\system32\shdocvw.dll for this code to work.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Get all opened IE instances
        Dim shellWindows As SHDocVw.ShellWindows = New SHDocVw.ShellWindowsClass()
        Dim ie As SHDocVw.InternetExplorer
        For Each ie In shellWindows
            ' Get URL of IE instance
            Console.WriteLine(ie.LocationURL)

            ' Close specific IE tab / instance
            If ie.LocationURL = "http://sample.com/" Then
                ie.Quit()
            End If

        Next ie

    End Sub

Open in new window

0
 

Author Closing Comment

by:RobertoFreemano
ID: 34953038
Magic ;)
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

690 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