question

VivekRamesh-0096 avatar image
1 Vote"
VivekRamesh-0096 asked cooldadtx answered

Unable to get Edge browser instance in VBScript

Hi Team,

I'm trying to launch an URL in Edge browser through VBScript without a taskbar and status bar. Please find the snippet below.

 URL = "https://www.google.co.in/"
 Appli = "msedge about:blank"
    
 dim WshShell
 set WshShell = WScript.CreateObject("WScript.Shell")
 WshShell.Run Appli, 3
    
 dim objShell
 dim objShellWindows
    
 set objShell = CreateObject("Shell.Application")
 set objShellWindows = objShell.Windows      'Here i can able to get IE browser instance when i using iexplore but not the Edge
    
 dim objEdge
 dim Edge
 for each objEdge in objShellWindows
  if (not objEdge is nothing) then
    
             if isObject(objEdge.Document) then
                 set Edge = objEdge.Document
  if VarType(Edge) = 8 then
  objEdge.ToolBar = 0
                     objEdge.StatusBar = 0
                     objEdge.Navigate2 URL
  end if
  end if
  end if
  set Edge = nothing
         set objEdge = nothing
  Next

Could anyone please guide me to get the Ege browser's instance in VBScript?

Note: The same code working fine with IE, if I change msedge as iexplore in Appli variable.

Thanks in Advance,
Vivek Ramesh

ms-edge
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Castorix31 avatar image
0 Votes"
Castorix31 answered Castorix31 commented

> set objShellWindows = objShell.Windows 'Here i can able to get IE browser instance when i using iexplore but not the Edge

Edge does not use IE COM interfaces, so this cannot work...

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your response @Castorix31

Is any other way to achieve this?

0 Votes 0 ·

From this thread Interact with Edge/HTML through vbscript, with "WebDriver", but I did not test...



0 Votes 0 ·
cooldadtx avatar image
1 Vote"
cooldadtx answered

Edge is just a program. Use the standard VBScript code to start a process and pass the correct arguments.

Dim shell
Set shell = WScript.CreateObject("WScript.Shell")

shell.Run "msedge https://www.google.com --hide-scrollbars --content-shell-hide-toolbar"


Of course if Edge is already open then it'll open a tab in the current window instead. You'll have to play around with the various command line arguments to get the exact behavior you want.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.