0

I have a C# winforms application that logs into an online console, that uses reCAPTCHA to ensure that you are not a robot.

In my C# application, you have to solve it every time when you log in. However, when you log in via Firefox, you simply need to check the I'm not a robot checkbox, without solving the reCAPTCHA:

reCAPTCHA

I have set the IE Version in the registry, so other than that, I hove no idea what could govern this behavior. Can someone point me in the right direction?

Code to set IE Version:

private static void SetIE()
{
  int BrowserVer, RegVal;

  // get the installed IE version
  using (WebBrowser Wb = new WebBrowser())
    BrowserVer = Wb.Version.Major;

  // set the appropriate IE version
  if (BrowserVer >= 11)
    RegVal = 11001;
  else if (BrowserVer == 10)
    RegVal = 10001;
  else if (BrowserVer == 9)
    RegVal = 9999;
  else if (BrowserVer == 8)
    RegVal = 8888;
  else
    RegVal = 7000;

  // set the actual key
  using (RegistryKey Key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree))
    if (Key.GetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe") == null)
      Key.SetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe", RegVal, RegistryValueKind.DWord);
}

EDIT1 With IE Version 11.786.15063.0 you also need to solve the reCAPTCHA, as well as Edge.

RooiWillie
  • 2,198
  • 1
  • 30
  • 36

1 Answers1

0

If you're running this as Debug then it's likely that the application name is not what you expect and does not match the registry key you've created.

Try adding a key for YourAppName.vshost.exe and retry. Something like this might help:

// Assign the application name to a variable
var appName = System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe";

// If under debug replace it with the debug name
#if DEBUG
appName = System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".vshost.exe";
#endif 

// Your registry code
...
if (Key.GetValue(appName) == null)
  Key.SetValue(appName, RegVal, RegistryValueKind.DWord);

Alternatively run your Release build and see observe what happens.

Edit:

OP comments that if he browses to the site using Internet Explorer v11.786.15063.0 that the same issue occurs and you must solve the reCAPTCHA as opposed to simply checking the box.

In this case the answer is either accept the behaviour or don't use the WebBrowser control and instead use something like CefSharp.

Equalsk
  • 7,954
  • 2
  • 41
  • 67
  • I tried the release build - same issue still exists. – RooiWillie Dec 18 '17 at 12:13
  • What happens if you open this site in the actual Internet Explorer 11 (or whatever version you have), does it display the check box? – Equalsk Dec 18 '17 at 12:14
  • With IE Version 11.786.15063.0 you also need to solve the reCAPTCHA, as well as Edge, so this is actually related to IE vs Firefox. – RooiWillie Dec 18 '17 at 12:18
  • I've updated the answer based on this information. Basically you have to accept this as a limitation of the `WebBrowser` control, or use a different browser engine such as `CefSharp`. – Equalsk Dec 18 '17 at 12:21
  • Just to answer your question: whatismybrowser.com shows IE on Windows 8 on my app, but in IE it shows IE on Windows 10. – RooiWillie Dec 18 '17 at 12:25
  • 2
    As usual downvoters can't use them properly or leave a comment. _sigh_ – Equalsk Dec 19 '17 at 09:46