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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    182
    Thanks
    139
    Thanked 0 Times in 0 Posts

    Help Opening an Application from Javascript

    Hello,

    I need your help,

    I have the following code below, and its giving me an error saying: "The system cannot find the file specified".

    Code:
    <html>
    
    <script language="javascript" type="text/javascript">
    
    function start_ccm(){
    var wsh = new ActiveXObject('WScript.Shell'); 
    wsh.exec("C:\Program Files\WorkDynamics Technologies\ccmApplications\ccmMercury.exe")
    }
    
    </script>
    
    </head>
    <body>
    <input id="Button1" onclick="start_ccm()" type="button" value="START" />
    </body>
    </html>
    There is nothing wrong with the location, but my best guess are the spaces in the file path.

    Any help with this is greatly appreciated.

    Cheers,

    J

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    try this

    Code:
    <html>
    
    <script language="javascript" type="text/javascript">
    
    function start_ccm(){
    var wsh = new ActiveXObject('WScript.Shell'); 
    wsh.exec("file:///C|/Program Files/WorkDynamics Technologies/ccmApplications/ccmMercury.exe")
    }
    
    </script>
    
    </head>
    <body>
    <input id="Button1" onclick="start_ccm()" type="button" value="START" />
    </body>
    </html>

  • Users who have thanked DanInMa for this post:

    jason_kelly (09-29-2011)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    No, the shell's .exec really does want just a path, not a URL. So using file: would not help.

    I think he may be right about the spaces.

    Might be able to do this:
    Code:
    wsh.exec('C:\"Program Files"\"WorkDynamics Technologies"\ccmApplications\ccmMercury.exe')
    You might note that this kind of path works even in a DOS command prompt.

    For example, I just did
    Code:
        cd c:\"program files"
    in my DOS window, and it worked.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    jason_kelly (09-29-2011)


  •  

    Posting Permissions

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