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
    KXM
    KXM is offline
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Launch a system based program from a web page.

    I think this is fairly simple...

    I have creater a custom desk top, using a simple HTML doc.

    I would like to be able to launce any program on my HD from it.
    I know I can't just link to it, [this causes Windows to diplay a blank page as my desktop] and if I open it in a browser, it treats it like a download. [IE: save? ope? cancle?]

    Is there a simple way to make a Java script to just launch a program?

    TIA!!!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,244
    Thanks
    203
    Thanked 2,555 Times in 2,533 Posts
    No. There is no way that JavaScript can launch a program, thank the Good Lord!

  • #3
    KXM
    KXM is offline
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I had a feeling... And I agree VERY much... Save this one instance.

    THNX for the prompt responce. Any hints as to other options?

  • #4
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I looked into this sort of thing, a while back, and found that Internet Explorer can utilize the ShellExecute Method for launching applications

    Here's an example that requires an absolute path to each program (though this can be substituted a couple of ways):

    <html>
    <head>
    <title>-</title>

    <script type="text/JScript">

    function Launch(){

    var v;

    v = new ActiveXObject("Shell.Application");

    v.ShellExecute("some-file-name.exe", "", "C:\\some-folder\\a-subfolder", "open", 10);}

    </script>

    </head>
    <body>
    <button onclick="Launch()">program link</button> - (needs real file-names...)
    </body>
    </html>


    (The link to 'ShellExecute' [above] explains each of the parameters.)

    Something that might be easier (if your links are for programs that have desktop shortcuts) involves using the ssfDESKTOP constant of "0" (in place of an absolute path to each program's location), and the inclusion of only the name of a shortcut (instead of some-file-name.exe):

    v.ShellExecute("shortcut-name", "", 0, "open", 10);

    Another possible set up (perhaps the simplest, syntax-wise) is to copy your program shortcuts into the "windows", "system", or "system32" folder(s):
    Here you won't need to specify anything but the shortcut name (unless there's reason to 'recommend' a window size other than the program default):

    v.ShellExecute("shortcut-name");

    If you don't know (off-hand) where the official "system folder" is located, you can use its ShellSpecialFolderConstant value of 37 to open it, like so:

    <html>
    <head><title>-</title>
    <script type="text/JScript">
    function SysFold(){
    var v;
    v = new ActiveXObject("Shell.Application");
    v.Open(37);}
    </script>
    </head>
    <body>
    <button onclick="SysFold()">system folder</button>
    </body>
    </html>


    The real point, though, is that the ShellExecute Method shouldn't trip a dialog-box whenever you choose to launch a program from IE.

    Where Shell scripting is involved, it seems that we only have to confirm such operations (in each document) once -- and the message-box for this reads something like:

    "The file or folder you are opening contains Web content that may be unsafe. The Web content has either been modified or is from an unknown source. Do you want to allow it to be initialized and be accessed by scripts?"

    After choosing "Yes", you should not be asked again -- even when the document is closed & reopened (that is, unless its code has since been modified).


    The less important idea was that using shortcuts can reduce the syntax required for writing links to programs (and actually, the same thing can be done for any application located in the system folder(s) -- such as Notepad or MSpaint: no path or file extension is required...):

    <html>
    <head>
    <title>-</title>

    <script type="text/JScript">

    var v = new ActiveXObject("Shell.Application");

    </script>

    </head>
    <body>
    <p>
    <a href="javascript&#58;v.ShellExecute('some-file-name.exe', '', 'C:\\some-folder\\a-subfolder');">regular link (fake)</a>
    </p>
    <p>
    <a href="javascript&#58;v.ShellExecute('shortcut-name');">shortcut link (fake)</a>
    </p>
    <a href="javascript&#58;v.ShellExecute('Notepad');">link to Notepad.exe - in the system folder (if you have it there)</a>
    </body>
    </html>


    If none of this stuff works for you, there's another thread around here that's related to your topic (& has a lot of good information, regardless...).
    Last edited by swmr; 10-18-2003 at 09:12 PM.
    hmm... ?

  • #5
    KXM
    KXM is offline
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This works flawlessly!!!!! I can't thank you enough!!!!!


    THNX!!!


  •  

    Posting Permissions

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