Recent

Author Topic: Run windows exe on remote pc  (Read 18798 times)

rvk

  • Hero Member
  • *****
  • Posts: 6989
Re: Run windows exe on remote pc
« Reply #30 on: April 05, 2016, 01:15:56 am »
Inetpub is the localhost as set by IIS.
With Chrome it did not even write a text file (wampserver did).
I figured as much. But why are you mentioning IIS when your using Wamp? If you want to use IIS, did you install and configure PHP for it? If not... you shouldn't mix up your server-options.

And yes, as far as I can see now, if you want to expand and serve your report as a html, Wamp is a fine way to go for that purpose (or install Apache and PHP separately).

But like molly explained, if your application can run 24/7 you could also add a small thread listening on port 80 (it any other port and if a remote pc requests a certain page you can run the procedure to create the report and present the file add html through that port (essentially creating a little html-server yourself). If you don't want to do that you can go for the wamp method and do this in PHP. (Edit: also look at the last answer from molly)
« Last Edit: April 05, 2016, 01:19:57 am by rvk »

Zath

  • Sr. Member
  • ****
  • Posts: 391
Re: Run windows exe on remote pc
« Reply #31 on: April 05, 2016, 01:33:03 am »
Sorry rvk, I'm not the OP, I was just mentioning the IIS bit.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Run windows exe on remote pc
« Reply #32 on: April 05, 2016, 01:44:37 am »
@epergola
Seems i have to make small corrections to what i wrote earlier about using/testing the (bare without modifications) simplehttpserver:
1) you need to connect to port 8080 (or change the code to use another port) using your browser
and
2) you need f.i. to 'create' a html page in the same directory. If you add the name of the file (for example myview.html) to the url address bar of your browser then you should be seeing the contents of that file.

e.g. http://127.0.0.1:8080/myview.html

I think rvk made some good points. WAMP is perfectly capable of providing the same functionality with using PHP (and of course far better tested and using much more approved methods).

But as rvk perhaps noticed from my writings: it is oh so tempting to copy-paste those couple of lines inside your executable, having all inside the same executable. That is, if you are able to run that app 24/7, if not then you can always use the standalone httpserver approach and invoke your .exe that way.

So, i believe that means you have to make some decisions  ;D

epergola

  • Full Member
  • ***
  • Posts: 157
Re: Run windows exe on remote pc
« Reply #33 on: April 05, 2016, 01:57:19 am »
Thanks to both.
Molly NO, my.exe does NO run 24/7. It just seats there.
When the person with the mobiles wants to
run a report, he/she would use the mobile browser and write
"109.59.193.23//localhost/runmyexe.php".
This would execute the php that in turn execute my.exe.
That is what i like to do.
IN order to be able to run the php which will run my.exe on the PC, what do i need to have installed on the PC. Suppose I go with wampserver.
Just installed is enough? or it has to be in memory all the time in the PC?
And this line
"109.59.193.23//localhost/runmyexe.php". in the mobile browser  is in the correct format?
Thanks

balazsszekely

  • Guest
Re: Run windows exe on remote pc
« Reply #34 on: April 05, 2016, 06:20:59 am »
@epergola
It's perfectly fine to not knowing something, but asking the same question again and again it's a little bit strange. You already got your answers above(if you read the posts carefully).

PS: The whole idea of running an exe through a web server is fundamentally flawed. Yes it's possible, but it's not the right approach.

Thaddy

  • Hero Member
  • *****
  • Posts: 18975
  • Glad to be alive.
Re: Run windows exe on remote pc
« Reply #35 on: April 05, 2016, 06:39:57 am »
"109.59.193.23//localhost/runmyexe.php".
localhost is an alias for an ip 127.0.0.1
So that is wrong and won't work
Quote from: epergola
Suppose I go with wampserver.
Just installed is enough? or it has to be in memory all the time in the PC?
No there needs to be a webserver running all the time.
If you a concerned about resources, don't use a full WAMP stack.
Write a small webserver in FPC - simply use the example in fpweb or use something like tinyweb that just does what you want.
But you can use a cgi program with almost any webserver, including tinyweb.
The cgi can start the executable. (I have fpc running that way as a webservice, tnx l505!)
Quote from: epergola
And this line
"109.59.193.23//localhost/runmyexe.php". in the mobile browser  is in the correct format?
No it is not. It is nonsense. See above.
You don't seem to get that some complexity is involved.
As getmem wrote: it is possible, but not recommended.
But as you seem so persistent, read the thread again carefully.
All is already explained.

Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Run windows exe on remote pc
« Reply #36 on: April 05, 2016, 08:03:46 am »
It's actually pretty simple and doesn't even require IIS, Apache or the ugly PHP, it can be done in a standalone Pascal web service application. But since the OP lacks web configuration and programming experience, things become harder.

Brook example:
Code: Pascal  [Select][+][-]
  1. program ReportWebsite;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   SysUtils,
  7.   fpjson,
  8.   httpprotocol,
  9.   BrookUtils,
  10.   BrookAction,
  11.   BrookHttpDefs,
  12.   BrookFCLHTTPAppBroker,
  13.   BrookApplication;
  14.  
  15. type
  16.  
  17.   { TReportAction }
  18.  
  19.   TReportAction = class(TBrookAction)
  20.     procedure Get; override;
  21.   end;
  22.  
  23. { TReportAction }
  24.  
  25. procedure TReportAction.Get;
  26. var
  27.   ExitCode: Integer;
  28.   EOSE: EOSError;
  29. begin
  30.   try
  31.     ExitCode := ExecuteProcess('/path/to/your/report/generating/exe',['parameters','if','required']);
  32.     if ExitCode = 0 then
  33.       // read the generated report and send as response here,
  34.       // either displayed in browser or download, up to you
  35.     else begin
  36.       EOSE := EOSError.Create('Abnormal termination');
  37.       EOSE.ErrorCode := ExitCode;
  38.       raise EOSE;
  39.     end;
  40.   except
  41.     on e: Exception do
  42.       if e is EOSError then
  43.         // generate error response, use (e as EOSError).ErrorCode for analysis
  44.       else
  45.         // generate generic error response, i.e. use e.Message
  46.   end;
  47. end;
  48.  
  49. begin
  50.   TReportAction.Register('/report');
  51.   BrookSettings.Port := 4444;
  52.   BrookApp.Run;
  53. end.
  54.  

Thaddy

  • Hero Member
  • *****
  • Posts: 18975
  • Glad to be alive.
Re: Run windows exe on remote pc
« Reply #37 on: April 05, 2016, 09:09:12 am »
I missed a small detail, but nice example.
The url to reach that server should be in your case:

109.59.193.23:4444/report.

I suspect the OP is not familiar with a service running from a non-standard port.

Or am I wrong?

Also: brook seems a mature framework by now, but it is a separate download?
fpweb is included in the standard distribution.
« Last Edit: April 05, 2016, 09:13:46 am by Thaddy »
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Run windows exe on remote pc
« Reply #38 on: April 05, 2016, 09:33:52 am »
Also: brook seems a mature framework by now, but it is a separate download?
Yes, it's a 3rd party package from silvio.
fpweb is included in the standard distribution.
Which you can do in it also, only slightly longer code for pure hand coding since the framework is somewhat designed with RAD in mind.

 

TinyPortal © 2005-2018