This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Open cmd.exe to run another program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Open cmd.exe to run another program" Watch "Open cmd.exe to run another program" New topic
Author

Open cmd.exe to run another program

s oc
Greenhorn

Joined: Aug 02, 2006
Posts: 5
Hi,

I'm having problems trying to open the command prompt even when i use the full path but don't have any problems opening other files like mspaint or notepad. Here is the code I am using:

Runtime.getRuntime().exec("cmd.exe");

Also, I need to run another program through the command prompt called foremost.exe which has to be run through the command prompt. When it is executed on the command prompt it should look like this:
c:\foremost [imageFileName.dd]

Any ideas would be much appreciated

shinny
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi,

Welcome to JavaRanch!

You'd want to do something like

Runtime.getRuntime().exec("cmd.exe /c formost imageFileName.dd");


[Jess in Action][AskingGoodQuestions]
s oc
Greenhorn

Joined: Aug 02, 2006
Posts: 5
Thanks Ernest that worked fine, you're a star
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Open cmd.exe to run another program