Results 1 to 4 of 4
Thread: Execute external file/program
- 04-21-2009, 09:31 PM #1
Execute external file/program
I am looking for a code snippet which executes a file at any given location.
If it was given the location, "E:\Manuals\readme.txt".
It would open up the specified text document using the default program.
Or if it was given the location, "E:\games\game.exe".
It would execute the game.
Basically it acts as if the user has just double clicked on the file.
I have tried the following, but to no success. ("CreateProcess error=193, %1 is not a valid Win32 application")
Runtime.getRuntime().exec("bin/test.txt").waitFor();They're 10 people in the world, those who speak binary, and those who dont.
^ Lame i know, but i can actually count in it nowadays! :eek:
- 04-21-2009, 09:47 PM #2
If I remember correctly you have to specify the program to use to open it.Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
- 04-21-2009, 10:22 PM #3Senior Member
- Join Date
- Sep 2008
- Rep Power
a file can either be run or not. if a file cannot be run, you need to specify what you need to run it. you can do this based on extension.
- 04-22-2009, 12:35 AM #4
- By 2bGeek in forum AWT / SwingReplies: 3Last Post: 02-21-2009, 01:59 AM
- By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 03:40 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 02-05-2008, 10:14 AM
- By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 10:33 PM
- By romina in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:28 AM