简体   繁体   中英

How to trigger a desktop application from my website?

I need to do click a button within the admin side of my external website and cause it to trigger an application within my local workstation (with parameters based on button). I have full control of the server, PHP, etc. I can also install any application on my workstation. What is the best way to do this? Adobe AIR/Flash? Java?

I need something simple and I am open to all ideas.

You can launch the program from a signed java applet. Try something like this:

String cmd = "notepad.exe";

try {
  Runtime rt;
  rt = Runtime.getRuntime();
  Process p = rt.exec( cmd );
  System.out.println( "Exit Value = " + p.waitFor() );
} catch ( IOException e ) {
  e.printStackTrace();
} catch ( InterruptedException e ) {
  e.printStackTrace();
}

Probably the easiest thing to do is to use a protocol other than HTTP. For example, Apple uses webcal:// urls to open iCal and subscribe to calendars. Your application will get the URL passed to it, and you can do whatever you like based on the data in the URL.

Here's on article on how to do this with Mozilla:

https://developer.mozilla.org/en/web-based_protocol_handlers

您可以将应用程序注册到URL协议 (已提供Windows链接)。

You could do this in Java by having a listener on your workstation watch for a file that an applet from the site admin writes to, but that could be hard.

Flash/AIR would be more of a pain if you don't already have Flash CS4 or later, but it might be easier if you do. I don't know of a way to communicate directly between Flash and AIR, but there's probably something out there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM