Search code examples
internet-exploreradminautoit

AutoIt - Crash without #RequireAdmin for opening a url


If I run in test.au3 :

#requireadmin
#include<IE.au3>

$oIE = _IECreate("www.google.com", 0, 1, 0, 1)

It successfully opens a new Internet Explorer window and navigates to www.google.com.

Now if I remove #requireadmin and run:

#include<IE.au3>

$oIE = _IECreate("www.google.com", 0, 1, 0, 1)

It just opens the window and doesn't navigate to the URL. Around 15 seconds later it crashes with:

---------------------------
AutoIt Error
---------------------------
Line 272  (File "\\intra.saaq.net\sb\du\du02\gar25\Desktop\outil_outlook\sources\Include\IE.au3"):

$oObject.navigate($sUrl)
$oObject^ ERROR

Error: The requested action with this object has failed.
---------------------------
OK   
---------------------------

Why is #requireadmin required to simply navigate to a URL? Is there any way around it?

Using AutoIt3.exe - 3.3.14.0


Solution

  • This appears to be a Windows security issue.

    The AutoIt help for _IECreate() describes a few work-arounds; the #RequireAdmin being one of them...

    New security in Windows Vista causes a new browser window to be created when a browser is instructed to navigate to a URL in a different security zone.

    This occurs as well with the initial creation and navigation initiated with _IECreate().

    The new window is a new browser instance and the previous browser object variable no longer points to it.

    There are several workarounds:

    1) add #RequireAdmin to your code (this is required even if the account is part of the Administrator's Group and will prompt for credentials if necessary),

    2) use _IEAttach() to connect to the new browser window

    3) add the target website to the Trusted Sites security zone in IE,

    4) turn off "Protected Mode" in IE,

    or 5) disable UAC. Care must be taken to understand the implications of disabling IE security features when accessing untrusted sites.