How to launch an exe from a JSP/ Javascript page

Posted on 2006-05-14
Last Modified: 2008-03-03

I have an exe present in the local machine. I need to launch the exe when the users clicks on a link. I have already tried
           href = "file:///c:/windows/notepad.exe"
This works when I run the file individually, but fails when I run the page from a JSP project.

Please advice.
Question by:Pentech
    LVL 23

    Expert Comment

    This works in IE:

    <a href="javascript:LaunchApp()">Launch the executable</a>

    function LaunchApp() {
     if (!document.all) {
      alert ("Available only with Internet Explorer.");
     var ws = new ActiveXObject("WScript.Shell");

    Author Comment


    We need an option that works on all browsers like Mozilla, Netscape etc.


    Accepted Solution

    LVL 3

    Assisted Solution

    Create a new page and just use to call the notepad. The new page should be in a <iframe>


    Runtime r = Runtime.getRuntime();
    Process p = null;
    p = r.exec("c:/windows/notepad.exe");
    catch(Exception e)

    In your JSP page,

    <a href="javascript:LaunchApp()">Launch the executable</a>

    function LaunchApp() {
          document.Notepad.src = "notepad.jsp";

    <iframe name="Notepad" src="blank.htm" width="0" height="0">

    Hope it helps

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Title # Comments Views Activity
    unit test DAO layer 1 132
    AlarmClock Challenge 35 143
    TreeSet comparator example 7 86
    main method of string class 3 62
    If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
    For Sennheiser, comfort, quality and security are high priority areas. This paper addresses the security of Bluetooth technology and the supplementary security that Sennheiser’s Contact Center and Office (CC&O) headsets provide.  
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now