Internet Explorer: Editing User Agent String so it is Seen By the Server

6,508

Solution 1

This was possible at one point in time, but the feature has been deprecated and is no longer directly supported.

The difference between the user agent string reported during HTTP negotiation ("seen by the server") and the value reported through the DOM property is a deliberate change designed (in part) to cope with people overloading the user-agent string in precisely this fashion.

The first article describes a set of registry values that adjusted the DOM user agent string at one time; it's possible that the Post Platform settings continue to work. You would need to adjust the settings for all client machines running the tool.

If the Post Platform changes don't pan out, you'll need to consider a different approach, perhaps one utilizing a cross-platform strategy.

Hope this helps...

-- Lance

Solution 2

You could use the "developer tools" from IE.

Just press F12 to activate it.

  • On older versions, it is under the tools menu, change user agent string and customize it.

  • On newer ones, it is under the emulation menu.


After some research, I located a few registry entries that you could tweak to change part of the UA string.

A clean IE11 on Win7 uses Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko

Win8 uses NT 6.3 an typically adds a Touch somewhere.

I think those default values cannot be changed by registry, nevertheless I think you could get rid of most of the .NET and other stuff it gets added by deleting the entries under

  • [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform]
  • [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform]

Just take into account that compatibility mode on IE also changes the UA string to show a former IE version to "force" the server into thinking it is an older version (I thing it uses IE6 or 7), so maybe most of what you want will be render useless if somebody needs to use compatibility mode to load a webpage.

Share:
6,508

Related videos on Youtube

Beems
Author by

Beems

Updated on September 18, 2022

Comments

  • Beems
    Beems over 1 year

    OS: Windows 7/8
    Browser: Internet Explorer 11
    Platform: x86

    How can I edit the user agent string on a machine to be universally seen by server-side code and web server logs? This needs to be a permanent, deployable solution, so something like using the Developer Tools likely won't work long-term.

    The only way I've been able to set/modify a user agent string for Internet Explorer so that it is seen by a remote web server is to use the following registry key\value:

    Key:   HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Version
    Value: SomeTestString
    Data:  NULL
    

    The above is what apparently is utilized by the Group Policy setting Windows Components\Internet Explorer\Customize User Agent String.

    If you add the key/value as shown above, your user agent would appear as something like Mozilla/5.0 (SomeTestString; Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko Unfortunately, this prepends the custom string you add to the user agent string, which breaks many Google sites and Netflix (and probably many many more)

    Using another registry key/value I found will show the user agent string via a JavaScript query, but it does not appear in the web site logs (not visible to the server):

    Key:   HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent
    Value: SomeTestString
    Data:  NULL
    

    If you look in the web server's logs, you see only something like this: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko, but if you hit a page that uses JavaScript to show the user agent, you see something like this: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0; SomeTestString; rv:11.0) like Gecko.

    Any advice is appreciated, as I'm stuck with a string that breaks some sites if utilized. Note that we do need to specify a custom item in the user agent string to support a 3rd-party platform that we cannot control.

    • user1984103
      user1984103 almost 9 years
      What exactly is your question?
    • Beems
      Beems almost 9 years
      Edited to clarify as first sentence
  • Beems
    Beems almost 9 years
    Sorry, I clarified the question. I should have stated that I needed a permanent, deployable solution.
  • NuTTyX
    NuTTyX almost 9 years
    Could you please write what is the exact user-agent string you need?
  • Lance Leonard
    Lance Leonard almost 9 years
    At one time, version vectors would have been an ideal solution. However, they depend on conditional comments, which were disabled in IE10. Sorry. :-\
  • andrej
    andrej almost 6 years
    Hello @Lance, could you please provide info about deprecation of User-agent registry keys? I can not find any info about deprecation on provided url. Thanks!
  • Lance Leonard
    Lance Leonard almost 6 years
    @andrej - I'm don't think there ever was an official statement, per se. RegKeys were always considered unsupported (so dev could change implementation without worrying about compat). The closest I can find now is near the bottom of docs.microsoft.com/en-us/previous-versions/windows/…, which says that, as of IE10, the pre/post platform keys were reported only through navigator.userAgent. Now that IE is officially unsupported, these old docs are getting harder and harder to find. (I'm not sure that's a bad thing.)