Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need help creating javascript to run CD executables

    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>

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think this will work:

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

    Happy coding!
    Last edited by nolachrymose; 12-25-2003 at 08:36 PM.

  • #3
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If the page that is running the script is on the actual CD, you could do this:

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

    Happy coding!

  • #5
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Absolutely perfect

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •