Thursday, August 05, 2010

Internet Explorer 8 Automation with Flash content using VBScript on Windows 7 64 bit

First of all running automation of Internet Explorer with Flash Content on a 64 bit OS is not easy because by default the OS will launch 64 bit version of Internet Explorer instead of the 32 bit version.

InternetExplorer.Application.vbs

Set objIE = CreateObject( "InternetExplorer.Application" )
' specify the IE settings
objIE.Navigate "http://www.actimus.com"
objIE.ToolBar = true
objIE.Resizable = False
objIE.StatusBar = False
objIE.Width = 800
objIE.Height = 600
' Make the window visible
objIE.Visible = True
WScript.Sleep 2000
'objIE.Refresh
'objIE.Quit
'Set objIE = Nothing

Will lead to the following message

Flash Player on 64-bit operating systems

Products affected
You might be on this page because you can't view content with the Flash Player. This is likely because your computer is running a 64-bit Web browser on a 64-bit operating system and you are trying to install Flash Player. Flash Player does not run in most 64-bit browsers. If you attempt to download the Flash Player in a 64-bit browser that does not support Flash Player, you will see a message from Adobe and a link back to this page. To install Flash Player, use a 32-bit Web browser on your 64-bit operating system. All major browsers are available in 32-bit versions and the Internet Explorer 32-bit browser is the default browser on Windows 64-bit systems.


There are two InternetExplorer.Application objects on x64-bit systems, one for x32 bit, the other for x64. By default, the x64 bit version is launched when you call the object, because by default the x64 bit wscript.exe is used. But you can also launch the x32 bit version of the object by using the x32 bit version of wscript.exe and passing the vbs url to it as an argument:

--------------------------------------------------

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run("%windir%\SysWOW64\wscript.exe " & Chr(34) & "C:\test\InternetExplorer.Application.vbs" & Chr(34))

--------------------------------------------

The same works for all other x32 bit ActiveX objects in case you have to use them.

If you are using CoCreateInstance() of CLSID_InternetExplorer (to obtain an out-of-proc instance of iexplore.exe), you can pass one of these new flags in the dwClsCtx field to control which kind of server (32-bit or 64-bit) you get:

CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000, // Pick 32 bit server over 64 bit server
CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000 // Pick 64 bit server over 32 bit server

No comments: