wood burning stoves*
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
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: 24166
    
  30

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
 
Similar Threads
problem after installing mysql
How to find the running process by jar
Command Line from a jar
System Admin blocks cmd prompt, Java "Bypass"?
an idea