How to block a user agent string in IE11

internet-explorer-11user-agent

We are starting to upgrade our laptops to Windows 8 touch screen and we are finding out some of the older websites (Ones we cannot change) detect the touchscreen as a mobile device and will not load the website correctly. We are using IE11 in Desktop Mode.

Is there a way to change what userstrings we are passing to the web servers?

Best Answer

The problem with UAPick from Bayden Systems and also the method of using IE11s own "Development Tools" with F12, Ctrl+8, User Agent String, is that these setting do not survive a restart of IE11.

I did some testing with changing the values in the registry from the links @harrymc already provided.

First changing the HKEY_LOCAL_MACHINE one but that didn't take here.
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent

However changing HKEY_CURRENT_USER worked. (but is user specific)
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent

First the result without changes: (result from myip.nl)
This is for a Windows 8.1 64bit with IE11 v11.0.9600.16384.

User agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko 
Browser: Unknow browser. 

I made a IE9.reg with the following:

REGEDIT4

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent]
@="Mozilla/5.0"
"Compatible"="compatible"
"Platform"="Windows NT 6.1"
"Version"="MSIE 9.0"

This completely changes your "User Agent String". After executing it i got:

User agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko 
Browser: Internet explorer 9.0 

But this would also change your "Platform". I would leave that one out. (You could also leave "Mozilla" on the default.)

Maybe, if your webpages only looks for MSIE, it's sufficient to only change the Version-information. Platform and "Mozilla" can remain untouched so websites can still identify it correctly. I also added the Compatible-tag. Maybe that's also used.

REGEDIT4

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent]
"Compatible"="compatible"
"Version"="MSIE 9.0"

This results in:

User agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko 
Browser: Internet explorer 9.0 

The string given by the Development Tools (F12, Ctrl+8, User Agent String) gives for IE9 is:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)

This seems closest to the original and adds the ability to identify it as IE9 compatible.

I don't know what exactly in your "User Agent String" triggers your websites to 'give' a mobile view (you didn't specify your UA) but playing with these values should fix it and these settings survive a restart of IE11 and the PC.


Edit:
So the problem is the Touch in:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/7.0; Touch; LCJB; rv:11.0)

IE doesn't give you the possibility to change (or remove) the parts it adds itself. We can change Compatible, Platform, Version and can add Pre and Post Platform tokens. (although Version won't be in send IE11 anymore and Pre and Post Platform won't be send in the header.)

You could try setting the compatibility mode to see it Touch is still there. (Did you try that already ?) If that works you could add the troubled sites to the list so they always display in compatibility mode.

If IE keeps on insisting to send Touch you could try mangling the UA with an extended Platform-key.

REGEDIT4

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent]
@="Mozilla/5.0"
"Platform"="Windows NT 6.1; Trident/7.0; rv:11.0) // ("

This way your UA would be
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/7.0; rv:11.0) // (; Trident/7.0; Touch; LCJB; rv:11.0)
and hopefully the site has more trouble finding Touch between the first ( and ).

If that doesn't work the only option would be a add-on which would override the UA (like UAPick but one which would be permanent after restarts).


Edit #2:

Found another option. If the site scans the whole UA it will find Touch. With the following you mangle the Platform-part of the UA with a linefeed so it will definitely not find it: (I found this solution here)

Make a notouch.vbs-file with the following:

Dim oShell
set oShell = CreateObject("WScript.Shell")
oShell.RegWrite "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Platform", "Windows NT 6.1; Trident/7.0; rv:11.0)" & vbLf & "IGNORE: (", "REG_SZ"
Set oShell = Nothing

(notice the & vbLf & "IGNORE:-part)

After executing the .vbs, the platform-part has a linefeed and after that an IGNORE-line. It will look like this in the headers:

User agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/7.0; rv:11.0)
IGNORE: (Windows NT 6.1; Trident/7.0; Touch; LCJB; rv:11.0)

See... no more Touch in the User agent line ;)
(it's a hack, but hey... it works)

Related Question