How to find the Internet Explorer binary

Raymond Chen


For some reason,

some people go to enormous lengths to locate the Internet Explorer
so they can launch it with some options.

The way to do this is not to do it.

If you just pass “IEXPLORE.EXE” to

the ShellExecute function

[link fixed 9:41am],
it will go find Internet Explorer and run it.

ShellExecute(NULL, “open”, “iexplore.exe”,
“”, NULL,

The ShellExecute function gets its hands dirty so you don’t have to.

(Note: If you just want to launch the
URL generically, you should use

ShellExecute(NULL, “open”, “”,

so that the web page opens in the user’s preferred web browser.
Forcing Internet Explorer should be avoided under normal circumstances;
we are forcing it here because the action is presumably being taken
response to an explicit request to open the web page specifically
in Internet Explorer.)

If you want to get your hands dirty, you can of course do it yourself.
It involves

reading the specification from the other side
, this time

the specification on how to register your program’s name
and path
(“Registering Application Path Information”).

The document describes how a program should enter its properties
into the registry so that the shell can launch it. To read it
backwards, then, interpret this as a list of properties you (the launcher)
need to read from the registry.

In this case, the way
to run Internet Explorer (or any other program)
the same way ShellExecute does
is to look in
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE (substituting
the name of the program if it’s not Internet Explorer you’re after).
The default value is the full path to the program and the
the “Path” value specifies a custom path that you should prepend
to the environment before launching the target program.

When you do this,
don’t forget to call

the ExpandEnvironmentStrings function

if the registry value’s type is REG_EXPAND_SZ.
(Lots of people forget about REG_EXPAND_SZ.)

Of course, my opinion is that it’s much easier just to let
ShellExecute do the work for you.

Raymond Chen
Raymond Chen

Follow Raymond