Jump to content

Change User Agent in IE?


Recommended Posts

My goal is to change the user agent for internet explorer to something else (for the whole process/session and not just one page). Been searching and haven't found a clear answer as to how to do this, if anyone can give me a little helping hand I'd appreciate it, thanks.

Tried, but didn't work out well for me (can't say I really understood it in the first place though):

Code I'm working with

#include <IE.au3>
$URL = "http://google.com"
$URL2 = "http://youtube.com"
$OIE = _IECREATE("http://msn.com")
_IENAVIGATE($OIE, $URL, $URL2)
Edited by Ranger08
Link to comment
Share on other sites

Try doing it like this.

Local $sUserAgent = "Agent User 1.0"
Local $skey = "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings"
If @OSArch <> "X86" And @AutoItX64 Then $skey = "HKEY_CURRENT_USER64SoftwareMicrosoftWindowsCurrentVersionInternet Settings"
Local $Write = RegWrite($skey, "User Agent", "REG_SZ", $sUserAgent)
If Not $Write Then Exit MsgBox(16, "Error!", "Something went wrong while trying to set the useragent.")
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)

Edit: Do not run the first one, I remembered the data type of that key, this one is correct.

Edited by ApudAngelorum
Link to comment
Share on other sites

Thanks for the reply, didn't work for me, here's the exact code i used

#include <IE.au3>
$URL = "http://google.com"
$URL2 = "http://youtube.com"
$OIE = _IECREATE("http://whatsmyuseragent.com")
Local $sUserAgent = "Agent User 1.0"
Local $skey = "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings"
If @OSArch <> "X86" And @AutoItX64 Then $skey = "HKEY_CURRENT_USER64SoftwareMicrosoftWindowsCurrentVersionInternet Settings"
Local $Write = RegWrite($skey, "User Agent", "REG_SZ", $sUserAgent)
If Not $Write Then Exit MsgBox(16, "Error!", "Something went wrong while trying to set the useragent.")
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
_IENAVIGATE($OIE, $URL, $URL2)
Edited by Ranger08
Link to comment
Share on other sites

#include <IE.au3>
Local $URL = "http://google.com"
Local $URL2 = "http://youtube.com"
Local $sUserAgent = "Agent User 1.0"
Local $skey = "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings"
If @OSArch <> "X86" And @AutoItX64 Then $skey = "HKEY_CURRENT_USER64SoftwareMicrosoftWindowsCurrentVersionInternet Settings"
Local $Write = RegWrite($skey, "User Agent", "REG_SZ", $sUserAgent)
If Not $Write Then Exit MsgBox(16, "Error!", "Something went wrong while trying to set the useragent.")
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
$OIE = _IECREATE("http://whatsmyuseragent.com")
Sleep (500000)
_IENAVIGATE($OIE, $URL, 1)

Now?

Link to comment
Share on other sites

Thanks

Checked regedit and saw that the change was applied to the user agent, don't know why none of the sites I use to check the user agent aren't showing the change. Tried flushing DNS/Cache, same result. Could there possibly be an alternative way?

Edited by Ranger08
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...