tags:

views:

52

answers:

2

Hi , This is a quick question.I just want to know if it is possible to invoke a .exe file on server side by an RPC from client? Thanks.

A: 

It could be possible, yes. But you'd have to make specific provision for it on the server and be very sure that it is secure and only runs when you want it to.

Example (from here):

<html>
<head>
    <script type="text/javascript">
        function runApp(which) {
        WshShell = new ActiveXObject("WScript.Shell");
        WshShell.Run (which,1,true);
        }
     </script>
</head>
<body>
   <font onClick="runApp('file://c:/windows/notepad.exe');" style="cursor:        
     hand;"><u>Notepad</u>
   </font>
 <br>

 <a href="runApp('file://c:/test.bat');">Batch File</a>
 </body>
 </html>
Ryan Bates
Everything runs on my local machine with no relation to the internet .(Client/Server is on same machine).Do i still have to do something specific to make it run or should I treat it as a normal case of server-side javascript calling .exe.
Manish
Assuming your on Windows, you can can use ActiveX to launch a process. I'll put some code in the answer.
Ryan Bates
@Ryan: I'd clarify that this isn't an RPC solution, and you're actually launching the executable from the *client*.
Daniel Pryden
Daniel is correct - this is not an RPC solution, just a quick and dirty workaround.
Ryan Bates
Well client side code wouldnt let me access the .exe so I had to go for this workaround :)
Manish
A: 

Is it possible to invoke an executable on the server side in response to a request from a client? Why yes it is, and there are in fact a myriad ways to do it, each with their own security issues.

The simplest to implement is the Common Gateway Interface (CGI).

But if you want your user (who is on the client end of the connect) to actually interact with the program (e.g. as you would with a desktop application) then you don't want to launch the program on the server side, you want to launch it on the client.

In your comment on Ryan Bates's answer, you say that you're running both the client and server on the same machine. That is an extremely odd configuration. Actually, it sounds like you don't really want to do client/server at all -- instead, you're effectively trying to write a desktop application in JavaScript. If that is the case, perhaps Mozilla XULRunner is more what you're looking for?

Daniel Pryden
Thanks ! I got it to work .I am developing a prototype on my local machine .....I wanted to access the .exe from the client side code but that would not be possible.I therefore use server side.If that helps I use GWT.
Manish
@Manish: What are you developing a prototype *for*? And why are you using GWT to build a desktop application? You do realize that if you're going to be building a web application, you won't be allowed to launch executables on your users' desktops, right?
Daniel Pryden
@Daniel :Yes I do ...I am developing a prototype for a web app but we need to test it first with "intended users" ..more like proof of concept ...for those purposes we have everything right now being developed on my machine ....later on UI would be running on client and .exe can be called on server
Manish