It's not a secret anymore!*
The moose likes Beginning Java and the fly likes How do you prevent command prompt pop-up/close it after a /C Start command? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do you prevent command prompt pop-up/close it after a /C Start command?" Watch "How do you prevent command prompt pop-up/close it after a /C Start command?" New topic
Author

How do you prevent command prompt pop-up/close it after a /C Start command?

Wayne Liu
Greenhorn

Joined: Dec 01, 2008
Posts: 1
As stated in the topic, can anyone show me the codes i need to prevent a command prompt pop up or close it after running a /C Start command? The code below will start a command prompt and "echotoscreen" is a .bat file with "echo %1, echo%2" commands that will accept the variables "msg" and "hp" respectively. Any help will be greatly appreciated! Thanks.

-------------------------------------------------
import java.io.*;

public class Test4 {
public static void main(String args[])throws IOException
{
String msg = "\"Your OTP is 493043\"";
String hp = "93495029";
Process p=Runtime.getRuntime().exec("cmd /C start echotoscreen " + msg+" " +hp);
BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=reader.readLine();
while(line!=null)
{
System.out.println(line);
line=reader.readLine();
}

}

}

-------------------------------------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you prevent command prompt pop-up/close it after a /C Start command?
 
Similar Threads
Help with Chat software
opening a new cmd and writing to it
try to run commands in command prompt by using java
bufferedwriter/filewriter...
How to get the system variable in UNIX?