Geeks With Blogs
Darren Fieldhouse

I recently had a request from a client for an application that could be distributed and run from a USB memory stick. I wrote it in .NET of course, but some of the target machines don’t have the .NET framework installed (it’s getting more common, but it’s not ubiquitous yet).

This wouldn’t have been a problem if we were installing the application because the installer would have taken care of that for me, but because it was designed to run from the USB memory stick I needed to write a bootstrap that could detect if .NET was installed; if it was installed go straight into the program, if not ask the user if they want to install it (from the installer on the USB memory stick).

Not having the skills to write a C++ bootstrap I had to look elsewhere for a solution, and what I came up with was an HTML application. Basically, a HTML Application is a web page that has its extension changed to .hta, but because it is running from the local machine it has a higher security level that a web page would, meaning I can write a JavaScript function like this:

function launchApp(app)
    var wsh = new ActiveXObject("WScript.Shell");;

Add to that the fact that the version numbers of installed .NET frameworks are included in the user agent string, and I can write code like this to detect if the correct version of .NET is installed:

if (navigator.userAgent.indexOf(".NET CLR 3.5.") > -1)

And as I final bonus, it’s a web page so I can layout an information page about the product, with images, that is displayed if .NET isn’t installed.

I’ve never used HTML applications before, but even thought it’s an old technology I think it has some life in it yet. I’ll certainly think about it in future if I need a small app but can’t rely on the .NET framework being installed.

Posted on Friday, November 28, 2008 1:17 PM | Back to top

Comments on this post: Using a HTML Application (.htx) to install .NET

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © DarrenFieldhouse | Powered by: