Skip to content

Instantly share code, notes, and snippets.

@etcimon
Created September 13, 2015 18:11
Show Gist options
  • Save etcimon/d4894c36773dc73e17ac to your computer and use it in GitHub Desktop.
Save etcimon/d4894c36773dc73e17ac to your computer and use it in GitHub Desktop.
Internet explorer desktop application
On Error Resume Next
AppURL = "http://google.com"
AppToRun = "iexplore about:blank"
AboutBlankTitle = "Blank Page"
LoadingMessage = "Loading Google..."
ErrorMessage = "An error occurred while loading google. Please close the Internet Explorer with Blank Page and try again."
EmptyTitle = ""
'Launch Internet Explorer in a separate process as a minimized window so we don't see the toolbars disappearing
dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run AppToRun
dim objShell
dim objShellWindows
set objShell = CreateObject("Shell.Application")
set objShellWindows = objShell.Windows
dim ieStarted
ieStarted = false
dim ieError
ieError = false
dim seconds
seconds = 0
while (not ieStarted) and (not ieError) and (seconds < 30)
set objShellWindows = objShell.Windows
if (not objShellWindows is nothing) then
dim objIE
dim IE
'For each IE object
for each objIE in objShellWindows
if (not objIE is nothing) then
if isObject(objIE.Document) then
set IE = objIE.Document
'For each IE object that isn't an activex control
if VarType(IE) = 8 then
if IE.title = EmptyTitle then
if Err.Number = 0 then
IE.Write LoadingMessage
objIE.Top = 10
objIE.Left = 10
objIE.Width = 1024
objIE.Height = 740
objIE.ToolBar = 0
objIE.StatusBar = 0
objIE.Navigate2 AppURL
ieStarted = true
else
Err.Clear
ieError = true
WScript.Quit 1
Exit For
end if
end if
end if
end if
end if
set IE = nothing
set objIE = nothing
Next
end if
WScript.sleep 1000
seconds = seconds + 1
wend
if (not ieStarted) then
WScript.Quit 1
end if
set objShellWindows = nothing
set objShell = nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment