Results 1 to 4 of 4
  1. #1
    sirwiggles's Avatar
    sirwiggles is offline Member
    Join Date
    Feb 2009
    Posts
    31
    Rep Power
    0

    Default 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")

    Java Code:
    Runtime.getRuntime().exec("bin/test.txt").waitFor();
    Thanks for the help.
    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:

  2. #2
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    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.

  3. #3
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    6

    Default

    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.

  4. #4
    sirwiggles's Avatar
    sirwiggles is offline Member
    Join Date
    Feb 2009
    Posts
    31
    Rep Power
    0

    Default

    Thanks for clearing that up.
    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:

Similar Threads

  1. How to execute external EXE?
    By 2bGeek in forum AWT / Swing
    Replies: 3
    Last Post: 02-21-2009, 12:59 AM
  2. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  3. Using Runtime to execute external commands
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-05-2008, 09:14 AM
  4. Replies: 0
    Last Post: 10-04-2007, 09:33 PM
  5. Use a external file in my program
    By romina in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •