Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

run .exe from text file  RSS feed

 
Tai Yo
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering is it possible to run .bat or .exe file from text file, for example,
1st retrieving the File object from the file chooser, then grabbing its path and throwing it into the text file.
After by reading this path (find a location of program), execute .bat or .exe program?
For example, if 1st file in location: Libraries\Documents\pro.bat and location of 2nd file: E:\pro2.exe.
Then by storing this path to text file, execute it?
Actually I have done this parts:
- retrieve the File object from the file chooser and save it to text file.
But I don't know how to run it from text file.
Any help is really appreciated.
 
Stevens Miller
Bartender
Posts: 1443
30
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is what you are after, Tai, but have a look at the Runtime class's exec method, and see if it helps.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the OP post thrice. Even I am not sure what is the question

@Tai could you please rephrase?
 
Tai Yo
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read that we can store the path of the file in memory for example in a List<String> or List<File>. I would like to ask, if we save the location in memory, do we need to save it in every runtime?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anything saved in memory is lost when the JVMs terminates. Also memories cannot be shared across multiple JVMs. So if you want the file names to be persisted, then yes, the names should be stored in a persistent storage like a file or DB.

In pseudo code
1) Your application comes up
2) You read the persisted file
3) Use the Runtime class Stevens mentioned above to process the file
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!