tags:

views:

701

answers:

6

Hi 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 Do This?

+7  A: 

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
@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
@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
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
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
*type command* OHHh crap...
Yada
@Tim: I re-edited it to make the point more obvious.
SLaks
+1  A: 

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

Joe Koberg
A: 
<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 Simon
Did you try to run it on your computer? For your sake I hope it does not work
mfeingold
According to Google, there's no such function.
SLaks
Also, `myApp.exeLoader` should be `exeLoader`, and `'C:\program.exe` should be `'c:\\program.exe'`
SLaks
This Code Does Not Works.
atromgame
:o)    
DA
I'm really tempted to try this code :)
Amarghosh
you have typo in `myApp.runExectable`, the code will not work :P
S.Mark
+1  A: 

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
+1  A: 

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
nothing bad about that, imo. its run at your own risk in your own environment.
Shawn Simon
@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
A: 

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
This doesn't answer the question at all. He appears to be trying to launch an EXE in client-side JavaScript.
SLaks