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 11 of 11

Thread: open .exe

  1. #1
    p3x
    p3x is offline
    New Coder
    Join Date
    Dec 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    open .exe

    Hello,

    I have a HTML file from which I must open an .exe with an argument (the argument being an url). The problem is also that the .exe is not always located in the same place. It is however always located in the same place as the html file is.

    How could I get this to work in Javascript?

    Thanks in advance
    p3x

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    make the link to the exe relative...
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    p3x
    p3x is offline
    New Coder
    Join Date
    Dec 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, thanks for that suggestion. That still doesn't tell me how I can open an .exe from javascript Could you pls help me with that as well?

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <a href="#" onclick="location.href='file.exe'; return false" target="_blank">open file</a>
    the critical part is the red text
    *keep it simple (TM)

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by p3x
    I have a HTML file from which I must open an .exe with an argument (the argument being an url).
    You should look into WSH and HTA for this.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    p3x
    p3x is offline
    New Coder
    Join Date
    Dec 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I looked into WSH, like you suggested and I found a way to open the .exe with a parameter:

    test.html contains this: (amongst other things)

    var myshell = new ActiveXObject( "WScript.shell" );
    myshell.run( ' "c:/testfile.exe" '+varUrl+' ', 1, true );

    That works perfect to open testfile.exe with the varUrl as parameter. The only problem now is that testfile.exe is not always in C: root, it IS always in the same location as test.html. So somehow I have to replace C: with something variable...any ideas?

    P3x

  • #7
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by p3x
    The only problem now is that testfile.exe is not always in C: root, it IS always in the same location as test.html. So somehow I have to replace C: with something variable...any ideas?
    then surely you can just drop the drive identifier from the file path:

    Code:
     myshell.run( ' "testfile.exe" '+varUrl+' ', 1, true );
    *keep it simple (TM)

  • #8
    p3x
    p3x is offline
    New Coder
    Join Date
    Dec 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, tried that - and it seems that 'desktop' is the current directory. But that is NOT the directory the .exe is located... so that doesn't seem to work

  • #9
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you'll need to run a script to get the current drive and directory and then prepend that to the filename you're calling.
    *keep it simple (TM)

  • #10
    Regular Coder
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    197
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you are using activeX why dont you just get the currrent folder name?
    //Determine the installed path
    my_path = location.pathname;
    my_path = my_path.substr(1,(my_path.lastIndexOf('\\')));
    my_folder = XObject.GetFolder(my_path);

    where XObject is whatever you call your activeX FileSystemObject
    ez
    Animation Rule #64
    Poor quality images are often artistic,
    Poor quality sound is ALWAYS annoying.

  • #11
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's about it for IE, although there's no reason to get the folder object.

    An HTA is different. It allows for relative links with most MS automation objects, and has the commandLine property for getting a current path.

    Script files are different as well, having ScriptFullName & ScriptName properties.

    Unless you are willing to disable browser security settings, an HTA is probably what you're after.
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

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