Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to stop process running at CMD through Java 1

Status
Not open for further replies.

rohansr002

Programmer
Feb 19, 2010
15
IN
Hello friends i have written a Java code which access the CMD on WindowsXp through Java code, it works fine but This function is unstoppable i.e. you need to press "ctrl+C" key to terminate on cmd window, can anyone tell me how to terminate this function through Java. Please help..

The code written is as:

char ch='"';
String st="\\Memory\\Available bytes";
String str1="\\processor(_total)\\% processor time";
try {
Runtime.getRuntime().exec("C:\\WINDOWS\\System32\\CMD.exe /c typeperf "+ch+st+ch+" "+ch+str1+ch+" >> f:/mf.txt");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Need it urgently,
Thanks in advance...!!!
 
Not related to Java, but you can use the sc option of typeperf to determine the number of data to be collected

Cheers,
Dian
 
Thnaks , Will You Explain how to use it with TYPEPERF command? just give an simple example.
 
It's a good practise to post your sollutions so other people reading this thread can benefit from it

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top