As my first post here on TehDevs, I would like to welcome everyone to the site. Adam and I hope you enjoy reading about our experiences (and hopefully learning something along the way).
Now then, down to business.
I am going to go over some of the basic things I have learned recently about using an HTML application to launch an install from a CD/DVD.
Basically, the HTML app is used when the CD/DVD is run, instead of the normal executable file.
The following example will show you how to create a splash screen for your install, which will run the executable file after 3 seconds.
The file starts out like a normal HTML document, as shown:
The next bit of code in the file sets the characteristics of the application. Such things as Border, Scrolling, etc are defined here. Note that this portion of code is still inside the <head> element
The next part of the code is all javascript, defining the position of the window, what file to run after the splash screen is complete, etc.
The main thing to point out here is the function nextScreen(). This function gets fired when the onLoad even of the body is triggered, which we will see in the next segment of code. Before we can launch any type of file from this html application, we have to declare a new ActiveXObject and assign it to some variable (for this example, we use oShell). Whatever variable you declare for this will then launch your install executable via the Run(“filenameâ€) method. Note this assumes autorun.exe is in the SAME directory as the html app itself. self.close() is to close the html application after the autorun.exe has begun execution.
The final bit of code for this app is the <body> tag:
As the code reveals, when the body has loaded, set a timeout on the window, which calls the nextScreen() function defined in our javascript, that occurs after 5000 milliseconds (5 seconds). We assign a background image to the body like normal HTML and give it a style.
After you have all the code together in a file, save it with a file extension of HTA. For learning purposes, let’s assume we named ours tehdevs.HTA. Now when we create out autorun.inf file for our disc, instead of using the ‘OPEN=tehdevs.HTA’ command to launch the file, we have to use ‘SHELLEXECUTE=tehdevs.HTA’
That’s all there is to it. Burn all said files to a disc, insert into drive, and watch the magic begin (assuming you have autorun enabled, otherwise d-click your drive to launch).
Example Files:
autorun.inf
tehdevs.hta
splash.gif

Subscribe to TehDevs!
Can’t seem to get this code working from my desktop. The window doesn’t resize at all.
Runtime error has occurred
Dazzaa on 11.08.07Line 26: Access is denied
forgot to add OS = WinXP SP2
Dazzaa on 11.08.07Browsers, Firefox 2.0 and IE7
Dazzaa on 11.08.07Is it just the resize event not working, or are there other problems?
Can you post your code so I can take a look?
Calvin Allen on 11.08.07I wonder if its down to IE7 or Mozilla Firefox? (v2.0.0.9)
Only made a couple of TINY changes to your code…
TehDevs
// Define the splash window size. (Normally the dimensions of the image used as background)
var splashWindowWidth = 360;
var splashWindowHeight = 299;
// Calculate the splash window location.
splashWindowLeft = (window.screen.availWidth - splashWindowWidth) / 2;
splashWindowTop = (window.screen.availHeight - splashWindowHeight) / 2;
// Center the splash window on the screen.
window.moveTo(splashWindowLeft, splashWindowTop);
window.resizeTo(splashWindowWidth, splashWindowHeight);
//Check if running from CD or DVD
//var commandLine = oHTA.commandLine;
//var oShell = new ActiveXObject(”WScript.Shell”);
//oShell.CurrentDirectory = commandLine.substr(1,commandLine.lastIndexOf(”\\”) );
// Called by the onLoad timer
function nextScreen()
{
var oShell = new ActiveXObject(”WScript.Shell”);
//Commented out to run locally on your machines
Dazzaa on 11.08.07//oShell.Run(”autorun.exe”);
self.close();
}
Im sorry, but I havent the slighest idea what is wrong with this. My guess is some form of non-printable characters in the source code. Once I copied your code into my own file, I couldnt get it to run. However, the file I have for download works. Is that the one you were using, or did you copy it from the article?
Calvin Allen on 11.09.07ActiveXObject(â€WScript.Shellâ€) is not being recognised in firefox browser, but its getting recognised by IE….
Yoganand on 04.11.08^ Make sure you have ActiveX installed for FireFox. It is my understanding that FireFox does NOT ship with ActiveX preloaded.
Calvin Allen on 04.11.08