...

View Full Version : need help creating javascript to run CD executables



dlclark66
12-25-2003, 05:29 PM
First let me say I know very little about JS programming. What I have done so far has been with the help of friends.
OBJECTIVE
I am creating a CD with an intro html page. On this page I want to have links that will run .exe slideshows (15 of them). I have it working but only if you have the complete path to the executable including the drive letter. The problem is not all computers have the same drive letter for the CD.
Is there a way to lift the URL (more specifically the drive assignment) from the address bar when the index.htm is open (this will be the active CD drive in the current machine) and insert that letter in the path for the executables in the JS code?
I am enclosing the code I am using that works if the correct path is given for your review.
I hope this is not too longwinded, I just want to be complete and easily understood.
Thanks in advance
Dan

<script>
function fall()
{
var inputparms = "";
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "file://D:/fall03.exe";
if (inputparms != "")
{
var commandParms = document.Form1.filename.value;
}


oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
}
</script>
<a onclick="fall();">fall</a>

nolachrymose
12-25-2003, 09:32 PM
I think this will work:


var driveLetter = location.href.replace(/file\:\/+/i, '').charAt(0);

Hope that helps!

Happy coding! :)

dlclark66
12-26-2003, 03:43 AM
At the risk of sounding like a total idiot I have to ask where the line should be put. Also, should I change the path in the commandtoRun line.
Here is what I have done so far but it doesn't work.
Thanks for the help.
Dan

<script>
function fall()
{
var inputparms = "";
var oShell = new ActiveXObject("Shell.Application");
var driveLetter = location.href.replace(/file\:\/+/i, '').charAt(0);
var commandtoRun = "file://D:/fall03.exe";
if (inputparms != "")
{
var commandParms = document.Form1.filename.value;
}


oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
}
</script>

nolachrymose
12-26-2003, 04:56 AM
If the page that is running the script is on the actual CD, you could do this:


var driveLetter = location.href.replace(/file\:\/+/i, '').charAt(0);
var commandtoRun = "file://" + driveLetter + ":/fall03.exe";

Hope that helps!

Happy coding! :)

dlclark66
12-26-2003, 02:47 PM
Thank you so much, this works perfectly. This will really make this CD look professional.
I guess I am going to have to start studying Javascript.
Thanks again
Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum