PDA

View Full Version : Java button to open external .exe



Goran
08-05-2005, 10:55 AM
That would be the code to run external exe file in Java:

Process p = rt.exec("Program.exe") ;

But what I want is a button that runs an exe file from your HDD (eg. C:\program_files\Program.exe) or from my ftp.

I tried these in flash:

on(release){
fscommand("exec", "c:\yourdir\yourapp.exe");
}

But no luck, any ideas??

I had theat silly idea... I uploaded Shortcut of the exe file to my ftp, linked it to buttom and it worked, but you have to press run when the security warning pops up. I want to execute it without popup.

cr3ative
08-05-2005, 11:22 AM
"I want to execute it without popup."

Unfortunately, you wouldn't be able to run an executable on a visitors system without a popup. It'd be silly if you could, think of the security holes!

cr3

Twey
08-05-2005, 11:44 AM
Yup, that's a security feature of applets - you can only do certain things (read/write the user's hard drive, execute code, connect to servers other than the one from which the applet was served...) with the user's permission. The only way to do one of these things without the popup is to get the user to download the JAR archive first, then run it as an application rather than an applet.

Goran
08-05-2005, 04:47 PM
Download the JAR archive? Can you explain that a bit more please?

Anyway I think my first post isn't clear enuff.. What I want to do is run a program that is allready installed on customers computer. For eg. I want that notepad.exe (%SystemRoot%\system32\notepad.exe) runs on computer when ppl press the button. I don't want to execute the exe that isn't allready on customers computer.

Twey
08-05-2005, 05:30 PM
The same principle applies.
As for the JAR... the .jar file you upload with your classes in it, with some modification, can be executed by the user with a double-click. All you need to do is define a public static void main(String[]) to your Main-Class as defined in your manifest.

Goran
08-05-2005, 05:48 PM
Well that would be like clicking on shortcut, except you would have to download it first, so that wouldnt solve the problem, but tnx for the tip.

Looks like the "popup" solution is the quickest one.

Twey
08-05-2005, 06:39 PM
Yup.
You COULD just say "Open your favourite text editor." And I hope you'll be including support for other operating systems as well.