Click here to Skip to main content
15,878,543 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
I want to run a exe file on website . it must be run when my website is opened
Posted

You don't.

It's very difficult for very good reasons: Firstly security. If you can do it, then so can malicious websites. Secondly, not all devices that can view your website can execute EXE files: they may be Android or iOS phones, Raspberry Pi devices, or internet enabled fridges!

That's not to say it's impossible - but it is in 99.9999% of situations. The exception being when you can use an ActiveX control to run the exe. But...they only work with IE (because of the security problems none of the other browsers were stupid enough to implement them), they must be enabled (because of the security problems they are disabled by default) and the user must give permission for it to run (because of the security problems very few users say "yes" any more, thankfully).

I'd drop the idea, if I was you.
 
Share this answer
 
Comments
Praveen_P 17-Nov-14 0:42am    
Good explanation , +5
You cannot run an .exe file on your website. You can however, stream that file down to the client but a security issue would pop up letting the user know that you're passing an executable file to the computer which might cause a havoc in the system.

Somehow, there is an applet in HTML that can host a java application in it. So, you can run that Java application in your website, but .exe file is not runnable.

But, if you wanted to execute a command on the server, or run a process inside your server on any event on the website, you would use the

C#
// inside handling the event, 
System.Diagnostics.Process.Start("fileName.exe");
// runs on the server, not on the client


But I believe, you can pass down the parameters to your application, execute it there, and bring back the results you're trying to show to the user. This is also of a very low chances to execute on the client if you have had to execute on client, because clients might not have that executable on their end.

It is still not impossible, and can be executed on the user's end if and only if know the location of the executable on the cline't computer. For example, according to this answer[^] of SO, this code of ActiveX

JavaScript
<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:\\Windows\\notepad.exe");
}
</script>


would run that application you pass.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900