Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Launch an external exe
#1
Hello,

I am starting to migrate my VCL application to Intraweb. I'm not used to working with it. In my VCL code, I am running an external application with "ShellExecute". In Intraweb, I don't know how to do this.
Code:
ShellExecute(0 , 'OPEN' ,PChar(ExtractFilePath(Application.ExeName)+ '.\Application.exe'), Nil, Nil, SW_SHOW);
The .exe is located in the "wwwroot". Do you have any idea how to launch an .exe from my application?

I don't want the app to run in the web browser. I only want to launch an application from a click of a browser button. For example, we launch a Notepad.

Thanks.
Reply
#2
You can do this in IW, remember the Notepad will opened in your SERVER, not in local machine.
Reply
#3
Amelie, as Jose pointed out the app run from Delphi code will be started on the server. Some more detail:

FYI, when moving from VCL to web development one of the most important things to grasp is where various procedures are executing. It will eventually become natural/automatic but initially you will need to think about it. This is true for ALL web development.

Your Delphi code runs on the Server. It always runs on the server. While it creates or downloads controls and browser procedures (javascript) that run in the users browser, Delphi code itself runs on the server. So, any procedure you have that starts other apps will start them on the server. That also applies to any code that creates user interaction. IW can take care of those things for you in most cases (when browsers allow it), but you have to think about it as you transition.

If you are trying to start an exe from the user's browser, you will find that most browsers make that almost impossible for security reasons. IW will go as far as the browser will let it in most cases.

Dan
Reply
#4
Thank you for your very interesting explanation.

I managed to run with Delphi code:

Code:
ShellExecute(0 , 'OPEN' ,PChar(ExtractFilePath(Application.ExeName)+ '.\Application.exe'), Nil, Nil, 0);

This code is executed without problem
Reply
#5
(11-20-2021, 09:11 PM)Amélie Wrote: Thank you for your very interesting explanation.

I managed to run with Delphi code:

Code:
ShellExecute(0 , 'OPEN' ,PChar(ExtractFilePath(Application.ExeName)+ '.\Application.exe'), Nil, Nil, 0);

This code is executed without problem

Yes, it will execute but is it what you want?   

In the development environment you are almost always using the same machine for the client and server.   If you intend to see what the user sees then access your app from another machine.  It is a good idea to do that regularly when you are first doing web work (IW or any other).   An adjacent machine is handy to have.

In this case you would see the user web page on one machine and the launched application on the other (server development) machine.

Dan
Reply
#6
(11-20-2021, 03:38 PM)Amélie Wrote: Hello,

I am starting to migrate my VCL application to Intraweb. I'm not used to working with it. In my VCL code, I am running an external application with "ShellExecute". In Intraweb, I don't know how to do this.
Code:
ShellExecute(0 , 'OPEN' ,PChar(ExtractFilePath(Application.ExeName)+ '.\Application.exe'), Nil, Nil, SW_SHOW);
The .exe is located in the "wwwroot". Do you have any idea how to launch an .exe from my application?

I don't want the app to run in the web browser. I only want to launch an application from a click of a browser button. For example, we launch a Notepad.

Thanks.


This is not possible in the Web. Anything running on the browser can't access the local disk of the user.

Imagine if when you visited a side (created by a person with bad intentions) their web page could "see" what you have in your hard drive?

This is not an IntraWeb limitation, but a security measure imposed by the browser itself. From the browser you only have access to your own page. Nothing else.

In your specific case, whatever you are trying to do with the Notepad you must find another way to do it. For instance, if you are displaying a long text file to your user, you can allow him to download the file (and open it using his own text file editor - regardless if it is notepad or anything else), or you can present the text to they using your own control (e.g. a IWMemo).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)