Question : Killing and Restarting Explorer.exe in .Net

Hi,

I've created a piece of code that kills explorer.exe and opens Internet Explorer up with a link.  However, i have been asked to only restart Explorer.exe when the page with that link is closed.  Is that possible to do and if so, how?  Any code examples would be great.

p.s it doesn't have to be in VB.net.

Many thanks.

Dom
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As IntPtr, ByVal uExitCode As UInteger) As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each ObjPro As Process In Process.GetProcessesByName("EXPLORER")
            TerminateProcess(ObjPro.Handle, 1)
            Do Until ObjPro.HasExited = True
                Application.DoEvents()
            Loop
        Next

        System.Diagnostics.Process.Start("https://www.yahoo.com")
        Process.Start("Explorer.exe")

        Me.Close()

    End Sub
End Class

Answer : Killing and Restarting Explorer.exe in .Net

This works better...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Imports System.Diagnostics
Public Class Form1
    Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As IntPtr, ByVal uExitCode As UInteger) As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each proc As Process In Process.GetProcessesByName("explorer")
            TerminateProcess(proc.Handle, 1)
            Do Until proc.HasExited
                Application.DoEvents()
            Loop
        Next

        Dim ie As New Process()
        ie.StartInfo.FileName = "c:\program files\internet explorer\iexplore.exe"
        ie.StartInfo.Arguments = "http://www.yahoo.com/"
        ie.StartInfo.UseShellExecute = False
        ie.Start()
        ie.WaitForExit()

        Dim explorer As New Process()
        explorer.StartInfo.FileName = "C:\windows\explorer.exe"
        explorer.StartInfo.UseShellExecute = False
        explorer.Start()
    End Sub
End Class
Random Solutions  
 
programming4us programming4us