WebBrowser control, isolation and IE8 InPrivate mode

前端 未结 2 1645
你的背包
你的背包 2020-12-09 23:19

I have a need to run some automation tasks in a web browser control but I seem to be facing a few limitations/unknowns that I\'m not 100% sure how to resolve. The applicatio

相关标签:
2条回答
  • 2020-12-09 23:32

    No, you cannot run the WebBrowser control in InPrivate mode; it's simply not a supported scenario.

    Yes, you can run two instances of IE in InPrivate mode and isolate them from each other.

    Use the command line: iexplore.exe -private -nomerge

    0 讨论(0)
  • 2020-12-09 23:33

    Here's some code that will give you access to an InPrivate IE

    Friend Function Open(Optional ByVal Url As String = "about:blank", Optional ByVal WindowState As ProcessWindowStyle = ProcessWindowStyle.Hidden) As WebBrowser
    On Error Resume Next
    
    Dim Start As New ProcessStartInfo
    Dim Windows = New ShellWindowsClass
    Dim Count = Windows.Count
    Start.FileName = "iexplore.exe"
    Start.Arguments = "-private -nomerge " & Url
    If WindowState = ProcessWindowStyle.Hidden Then
      Start.WindowStyle = ProcessWindowStyle.Minimized
    Else
      Start.WindowStyle = WindowState
    End If
    Process.Start(Start)
    
    Wait.Reset()
    Do
      If Windows.Count > Count Then Exit Do
    Loop While Wait.Waiting
    
    Browser = Windows(Count)
    Browser.Visible = (WindowState <> ProcessWindowStyle.Hidden)
    Return Browser
    End Function
    
    0 讨论(0)
提交回复
热议问题