EXE from HTML: Critcal patches broke ShellExecute method. What now?

J

Josh Mayfield

Note: There is considerable background detail here, but I do have
three questions, which are clearly marked and appear right before the
sample code.

I have a legitimate need to launch an EXE from an HTML page on Windows
XP/Internet Explorer. The EXE is already locally installed, and the
HTML page is also viewed locally on the PC- it's not a web site. I
know of two ways to do this, both of which are featured in the sample
HTML file at the bottom of my post.

The first method, using the Shell.Application ActiveX Object, used to
work until I installed the latest critical Windows XP patches from
Microsoft. Before these patches were installed, you could click the
‘Launch Notepad.exe' button in my sample HTML file and the program
would start right up. (Note that my Internet security settings are
always at Medium, my Local intranet security settings are at
Medium-low, and I've never had to mess with the individual ActiveX
security settings to get this code to work.)

However, one of the following critical updates has broken the ‘Launch
Notepad' code. It doesn't matter what my Internet/intranet security
settings are, or whether I've enabled unsafe ActiveX scripting. My
list of suspects is: KB842773, KB840315, KB841873, KB839645. (I have
four computers running Windows XP SP-1 at my desk, and each has the
same version of Internet Explorer installed-
6.0.2800.1106.xpsp2.030422-1633. The Launch Notepad code stopped
working on two of them this week, and still worked on the other two.
As a test, I ran Windows Update on one of the working systems and
found that after the patches were applied, my code no longer worked. I
even restored that machine's pre-patched ghost image and confirmed
that the code worked again. Next, I ran Windows Update a second time,
and allowed the aforementioned patches to be installed. Again, it
broke my code.)

You can confirm whether you have these patches installed on your
machine a number of ways, but perhaps the easiest is to open your
Windows folder and look for ‘$NtUninstallKBxxxxxx' folders with names
matching the patches I listed.

And then there's the second method, used by the ‘Launch Regedit.exe'
button. While this will actually still launch the EXE file, it's
undesirable because it always prompts you with a dialog that starts
out "An ActiveX control on this page might be unsafe…" Note that this
even happened before the patches, again regardless of the
Internet/Local intranet security settings.

* QUESTION 1: Is there any way to get ShellExecute to work again once
the new critical updates are installed?

* QUESTION 2: Failing that, how can I get around the unsafe control
warning with the Wscript.Shell method, for a local HTML file that's
trying to launch a local EXE?

* QUESTION 3: Is there any OTHER way for an honest guy like me to
launch a local EXE from a local HTML file?

Thanks, and here's the sample HTML file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript" language="JavaScript">

function LaunchNotepad()
{
var launcher = new ActiveXObject("Shell.Application");
launcher.ShellExecute("Notepad.exe", "", "", "open", "1");
}

function LaunchRegedit()
{
var launcher = new ActiveXObject("WScript.Shell");
launcher.Run("Regedit.exe");
}

</script>
</head>
<body>
<form name="Form1">
<input name="ButtonNotepad" value="Launch Notepad.exe"
onclick="LaunchNotepad()" type="button"> <br>
<br>
<input name="ButtonRegedit" value="Launch Regedit.exe"
onclick="LaunchRegedit()" type="button">
</form>
</body>
</html>
 
F

Fox

Josh said:
Note: There is considerable background detail here, but I do have
three questions, which are clearly marked and appear right before the
sample code.

If you're running IE5.5 or better, try changing the file extension of
your "web" page to .hta (HyperText Application) -- which can be used to
turn IE into an application "shell". HTA's are automatically afforded
security permissions that should allow you to manipulate your system any
way you like (without certs, etc...).
 
F

Fox

Josh said:
Note: There is considerable background detail here, but I do have
three questions, which are clearly marked and appear right before the
sample code.

If you're running IE5.5 or better, try changing the file extension of
your "web" page to .hta (HyperText Application) -- which can be used to
turn IE into an application "shell". HTA's are automatically afforded
security permissions that should allow you to manipulate your system any
way you like (without certs, etc...).
 
F

Fox

Josh said:
Note: There is considerable background detail here, but I do have
three questions, which are clearly marked and appear right before the
sample code.

If you're running IE5.5 or better, try changing the file extension of
your "web" page to .hta (HyperText Application) -- which can be used to
turn IE into an application "shell". HTA's are automatically afforded
security permissions that should allow you to manipulate your system any
way you like (without certs, etc...).
 
G

Grant Wagner

Josh said:
The first method, using the Shell.Application ActiveX Object, used to
work until I installed the latest critical Windows XP patches from
Microsoft. Before these patches were installed, you could click the
‘Launch Notepad.exe' button in my sample HTML file and the program
would start right up. (Note that my Internet security settings are
always at Medium, my Local intranet security settings are at
Medium-low, and I've never had to mess with the individual ActiveX
security settings to get this code to work.)

Your code will work, if loaded in IE from a page located on either your
own hard drive, or a network resource (such as a network drive). Both of
these are considered the Local Computer zone and allow the code to work
properly. It will/should never automatically launch an executable if the
page is located on an HTTP/HTTPS server (assuming default security
settings).
* QUESTION 1: Is there any way to get ShellExecute to work again once
the new critical updates are installed?

No, that's obviously the point of the patch(es).
* QUESTION 2: Failing that, how can I get around the unsafe control
warning with the Wscript.Shell method, for a local HTML file that's
trying to launch a local EXE?

You can't without changing your default security settings, or adding the
site you are loading the page from to your list of Trusted Sites.
* QUESTION 3: Is there any OTHER way for an honest guy like me to
launch a local EXE from a local HTML file?

No. If there were a way for an "honest guy like you" to run a local EXE
unprompted, then there would be a way for a malicious person to run a
local EXE unprompted. Not being able to do what you want to do is a GOOD
thing.
 
J

Josh Mayfield

* QUESTION 1: Is there any way to get ShellExecute to work again once
the new critical updates are installed?

Thanks to Fox for the tip about changing the file extension to .HTA.
This indeed worked (for both of my launching methods). Unfortunately,
I was unable to use it because my HTM files are hosted by a shell EXE
that was developed by another team and is hardcoded to load a specific
HTM file (which is the one I needed to change).

Additional thanks to Joker, for explaining that the patches affected a
different security zone from the ones I was messing with. I have
looked into this and found that it is called the "My Computer Zone"
and it's the only one that's not configurable in the Internet Options
UI. (Which completely baffles me.)

I located the My Computer Zone's registry key, which is:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings\Zones\0]

And was able to tweak the settings there. Now both of my launching
methods work without popping up any annoying warnings, and without
requiring a filename change.
 
J

joker

It's not a zone on the Internet is why it's not in Internet Properties.

Only Web based zones go there because that's what Internet Explorer was
designed for. It just happens to also work in the "My Computer" zone as
well.

Josh said:
* QUESTION 1: Is there any way to get ShellExecute to work again once
the new critical updates are installed?


Thanks to Fox for the tip about changing the file extension to .HTA.
This indeed worked (for both of my launching methods). Unfortunately,
I was unable to use it because my HTM files are hosted by a shell EXE
that was developed by another team and is hardcoded to load a specific
HTM file (which is the one I needed to change).

Additional thanks to Joker, for explaining that the patches affected a
different security zone from the ones I was messing with. I have
looked into this and found that it is called the "My Computer Zone"
and it's the only one that's not configurable in the Internet Options
UI. (Which completely baffles me.)

I located the My Computer Zone's registry key, which is:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings\Zones\0]

And was able to tweak the settings there. Now both of my launching
methods work without popping up any annoying warnings, and without
requiring a filename change.
 
M

Mark Preston

thestrae said:
Thanks to all for getting this started. YES - there are reasons to
execute an EXE from an HTML page that have nothing to do with
vandalizing someones computer.

[snip "I Love You" misunderstanding]

There's a MILLION legitimate reasons to want to launch an exe without
having to get additional security warnings.
So tell me one - you STILL have not done. As far as I can see there are
none at all - EVER.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,585
Members
45,080
Latest member
mikkipirss

Latest Threads

Top