5

I need run an exe file from client side. The Exe file exist in my C:\ Directory. I need run this exe file from my WEB site.

How can I co this?

Amicable
  • 3,115
  • 3
  • 49
  • 77
atromgame
  • 434
  • 2
  • 12
  • 24
  • 1
    why would you expect somebody would allow that? It has obvious security problems. – Naveen Nov 24 '09 at 17:12
  • 7
    Let's hope you can't, imagine clicking on a link and having format.exe run on your pc. Not very pleasent. – Remo.D Nov 24 '09 at 17:13
  • 2
    For clarification, do you mean that you want the exe to run *on the server* in response to an action initiated on the website? This is possible. Do you mean that you want the exe to automatically be invoked on the *client* machine? This is not possible (unless there is a security hole in the browser) due to security reasons stated in answers. – Nathan Nov 24 '09 at 17:18
  • 2
    Some time ago, the web installers from Windows Update and Windows SDK kind of did this. You had to install an ActiveX prior though. This is not feasible in a public environment, but may be in a closed environment, like a company-internal web site. – OregonGhost Nov 24 '09 at 17:22
  • 3
    I threw up a little in my mouth reading this question. –  Nov 24 '09 at 17:24
  • 1
    I wonder if people are favoriting this question just for lulz or to actually learn how to do it. – Amarghosh Nov 24 '09 at 17:26
  • 4
    Sure you can do it. That's how most viruses get passed around. Granted, you usually have to exploit some really badly written web browser with security holes. – DA. Nov 24 '09 at 17:30
  • Possible duplicate of [Is it possible to run an .exe or .bat file on 'onclick' in HTML](https://stackoverflow.com/questions/18980957/is-it-possible-to-run-an-exe-or-bat-file-on-onclick-in-html) – Liam Dec 31 '18 at 11:26

6 Answers6

11

For security reasons, you cannot do this.

If you don't understand why, imagine if a website could execute cmd-evil /c del /q /f /s \*

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • 1
    @Amarghosh: Don't instruct people to run a command that you know will cause harm, some people may not be aware of what the command does. – MitMaro Nov 24 '09 at 17:27
  • 2
    @Amarghosh - flagged your comment because if @atromgame doesn't understand the inherent problems, he/she might follow your encouragement to run the command and cause harm to the computer. – John K Nov 24 '09 at 17:27
  • Hmm.. sounds plausible - deleted the comment. For the record, I asked him to test that command (which will delete files (**all of them**) from the user's machine) to know the frustration that a user might have if it was possible to run exes from websites. – Amarghosh Nov 24 '09 at 17:34
  • I edited your answer so that if some naive user copy/pastes your example it won't be disastrous. I trust the point is still obvious to anyone who would have understood it before... – Tim Sylvester Nov 24 '09 at 17:41
2

HTML page instructing the user to click on a link that points to a local file?

Joe Koberg
  • 25,416
  • 6
  • 48
  • 54
2

Actually, I'm ashamed to admit that I have implemented this in response to a specific requirement.

The way to do it is to make the user run an installer for your app on their machine, which implies that they agree to run your app. The installer associates a specific file extension with your app or a "helper" app, and the web site sends a file with that extension when it wants to start the app. The user has to interact at that point, opening the file with "YourHelperApp".

You can also do it with no UI intervention if you use a signed browser plugin, which is allowed to do basically anything, but of course that's browser- and platform-specific.

Tim Sylvester
  • 22,897
  • 2
  • 80
  • 94
  • nothing bad about that, imo. its run at your own risk in your own environment. – Shawn Nov 24 '09 at 18:18
  • @Shawn Not bad from a security point of view, but one of usability. Having to launch an app installed on your computer from a web page... ugh. – Tim Sylvester Nov 24 '09 at 22:11
1

You need to run it on the server or on the client? For security reasons neither is possible out of the box.

but with a proper configuration it is possible for both scenarios. To run it server side you will have to request proper permissions for your web app. To do it client side you will have to have the user to agree to download and install certain code which will do it

mfeingold
  • 7,094
  • 4
  • 37
  • 43
  • On Windows, it is possible to open an .exe file on the client-side using a [custom URL protocol](https://stackoverflow.com/questions/80650/how-do-i-register-a-custom-url-protocol-in-windows). – Anderson Green Jan 06 '22 at 03:09
1

Put your entire application in a DLL library, upload it to some static IP address server and read about WebDAV technology. All you need is a small DLL loader that will load the library from the network. It's all built-in windows since Win2000 if i remember correctly.

It works like this, in import table you specify IP address and web resource from where you want to load your library (usualy it's filled with stuff like KERNEL32.dll USER32.dll etc.)

So you need to patch your exe loader and change your library name from eg.

MYLIB.dll to

\xxx.xxx.xxx.xxx\MYLIB (no extension required)

where xxx is the static IP address (doesn't work with the hostname). Windows will take care of the rest :)

Have fun.

Bartosz Wójcik
  • 1,079
  • 2
  • 13
  • 31
  • This doesn't answer the question at all. He appears to be trying to launch an EXE in client-side JavaScript. – SLaks Nov 24 '09 at 19:14
-3
<script>
   var myApp = {};
   myApp.runExecutable = function(fileLocation, callback) {
      var exeLoader = window.getSystemContext();
      exeLoader.execute(fileLocation, callback)
   }
   myApp.runExecutable('C:\\program.exe', function() {
       alert('complete.');
   });
</script>
Shawn
  • 19,465
  • 20
  • 98
  • 152