• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 936
  • Last Modified:

How to launch a exe file using Hyperlink in ASP.net web form

How to launch a exe file using Hyperlink in ASP.net web form. i tried it it says it cannot find file even thought it exists.
0
zameer21
Asked:
zameer21
  • 6
  • 4
  • 2
  • +3
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
can u post the code?
0
 
Meir RivkinFull stack Software EngineerCommented:
basically u can use activex like the code below.
howvere, only IE has support for ActiveX, so this won't work in any other browser. The user must answer "YES" to a warning that the page is trying to execute ActiveX code.
<a href="javascript:LaunchApp()">Launch the executable</a>

<script>
function LaunchApp() {
 if (!document.all) {
  alert ("Available only with Internet Explorer.");
  return;
 }
 var ws = new ActiveXObject("WScript.Shell");
 ws.Exec("C:\\Program Files\\Adobe\\Photoshop 6.0\\Photoshp.exe");
}
</script>

Open in new window

0
 
zameer21Author Commented:
<asp:HyperLink Target="_blank" ID="HyperLink1" NavigateUrl="downloads/test.exe" runat="server">If you are not able to Play video,please download codec here.</asp:HyperLink>

sedgwick---
Also the file is on file server(share) which is mapped to webserver.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Meir RivkinFull stack Software EngineerCommented:
why not adding code behind to OnClick of the hyperlink control.
Protected Sub HyperID_Click(variables) Handles HyperID.Click
  -- server side code here -> execute your exe file
End Sub
0
 
zameer21Author Commented:
Hyperlink does not have click event right,
0
 
zameer21Author Commented:
Also i can open hyperlink on when code on my local server,but when i promote it to test, it says the file cannot be found.
0
 
Meir RivkinFull stack Software EngineerCommented:
just point to the JS function in the NavigationUrl property, check this code snippet:


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    <asp:HyperLink ID="HyperLink1" NavigateUrl="javascript:LaunchApp()" runat="server">HyperLink</asp:HyperLink>
    </form>
</body>
<script type="text/javascript">
    function LaunchApp() {
        if (!document.all) {
            alert("Available only with Internet Explorer.");
            return;
        }
        var shell = new ActiveXObject("WScript.shell");
        shell.run("notepad.exe", 1, true); 
    }

</script>
</html>

Open in new window

0
 
Meir RivkinFull stack Software EngineerCommented:
HyperLink for files with spaces in the path not working in Internet Explorer.
does the file located under folder with spaces?
0
 
Meir RivkinFull stack Software EngineerCommented:
0
 
zameer21Author Commented:
I still get the error
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
I am pretty sure its got the right filename.
0
 
AndyAinscowCommented:
NavigateUrl="downloads/test.exe"

I guess downloads is not a valid subdirectory of the current directory - replace it with a complete path.
0
 
MogalManicCommented:
What is the full path of test.exe?

Is downloads directory a subdirectory of your web app?
0
 
Tony McCreathTechnical SEO ConsultantCommented:
Try using

NavigateUrl="~/downloads/test.exe"

this indicates a path relative to the application/website folder.

Another possible option is to write your exe in silverlight, which can be run in a browser. Its a bit like Java Applets but for .Net

http://silverlight.net/
0
 
Ted BouskillSenior Software DeveloperCommented:
You can't do this either on the server nor the client. It's by design and for security reasons.

Java Applets or ActiveX controls run with very limited permissions within the browser process as a thread so access to the host operating system is tightly controlled.

Running an EXE would provide file access to the host operating system which is extremely dangerous for the client.
0
 
Ted BouskillSenior Software DeveloperCommented:
http:#26443330 is the correct answer.  It can't be done.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 4
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now