Unable to get Edge browser instance in VBScript

Vivek Ramesh 86 Reputation points
2021-07-15T11:32:32.057+00:00

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

Microsoft Edge Microsoft Edge development
0 comments No comments
{count} vote

Accepted answer
  1. Castorix31 90,521 Reputation points
    2021-07-15T12:10:21.683+00:00

    > 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...


1 additional answer

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2021-07-15T13:55:11.677+00:00

    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.

    2 people found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.