Is there a command to open a new Ikognito Tab with IE by using VBScript?

319 Views Asked by At

Hello Guys I'm here again.

I want to open an "Ikognito-Tab" in IE with VBScript. But i have no idea how I can do it (or if it is even possible). So I ask you all for help. Is there a command to open a new Ikognito Tab with IE by using VBScript?

Thanks

Jonas

1

There are 1 best solutions below

7
Deepak-MSFT On BEST ANSWER

I understand that you are trying to develop a VB script to launch the IE browser in private mode and want to perform some automation tasks.

I suggest you copy and paste the code below in a notepad and save the file with the .vbs extension.

dim IE

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("iexplore -private")

WScript.Sleep 1000

For Each wnd In CreateObject("Shell.Application").Windows
  If InStr(1, wnd.FullName, "iexplore.exe", vbTextCompare) > 0 Then
    Set IE = wnd

    Exit For
  End If
Next

IE.Navigate("http://localhost/form.html")

 Do While IE.Busy Or IE.readyState <> 4
    'Do nothing, wait for the browser to load.
  Loop

  Do While IE.Document.ReadyState <> "complete"
    'Do nothing, wait for the VBScript to load the document of the website.
  Loop
WScript.Sleep 1000
IE.Document.getElementsByName("fname").Item(0).Value = "abc"
WScript.Sleep 1000
IE.Document.getElementsByName("lname").Item(0).Value = "xyz"

When you run the above code then it will launch the IE browser in private window then it will navigate to the website and code will fill the data in the textbox.

Output:

enter image description here

Notes:

  1. Make sure to close all the IE instances before running this code.
  2. I did not get a direct way to create an IE application object with a private mode. So here I am first opening the IE in private mode using shell and then fetching that object to automate it.

Further, you can try to modify the code as per your own requirements.