Search code examples
c#internet-explorerprocessbhoredirectstandardoutput

Unable to communicate with an executable started from BHO via stdin / stdout when IE is in non admin mode


I'm writing an IE 11 extension (BHO), which should be able to start an executable, communicate with it via standard on/out streams and propagate results to the page accordingly.

All is peaches when running IE in admin mode. When IE is started in regular user mode, BHO is still capable of calling an executable, but communication with it breaks down: streams to/from executable do not get redirected (the executable output begins to appear in it own console and no longer arrive to BHO).

I start my process like so:

nativeAppProcess = new Process();
nativeAppProcess.StartInfo.FileName = NATIVE_APP_PATH;
nativeAppProcess.StartInfo.UseShellExecute = false;
nativeAppProcess.StartInfo.RedirectStandardOutput = true;
nativeAppProcess.StartInfo.RedirectStandardInput = true;
nativeAppProcess.Start();

I have full control of native app and IE extension, so suggestions for both are welcome.

Thanks!


Solution

  • Answering my own question here.

    Looks like the problem is related to integrity level of IE and the executable. According to this resource, those levels are:

    • System: Used by OS components, should not be used by applications.
    • High: Processes that are running elevated with full admin rights.
    • Medium: Processes launched in the normal fashion.
    • Low: Used by IE and Windows Mail to provide protected mode

    IE runs on the lower integrity level than the executable and therefore is prohibited to communicate to it. This page lists the alternative ways of communication.

    A quick solution is to lower default integrity level of executable (worked for me, but places restrictions on executable (such as access to file system etc)):

    icacls lowIODummy.exe /setintegritylevel Low