Invoking CMD line or any process through Java Program
package com.useHtmlUnit;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class PsExec {
public void execute() throws IOException
{
//use "the path of exe file (windows)", "CMD" , "Parameters")
ProcessBuilder pb = new ProcessBuilder("C:\\PsTools\\PsExec.exe", "ping", "www.google.com");
Process p = pb.start();
InputStream is=p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=br.readLine();
System.out.println(line);
while (line!= null)
{
System.out.println(line);
}
// pb.redirectErrorStream(true);
}
public static void main(String args[]) throws IOException
{
PsExec p=new PsExec();
p.execute();
System.out.println("completed!");
}
}
It was very nice article and it is very useful to Selenium learners.We also provide Cub training software online training.
ReplyDeleteSelenium training in Chennai
ReplyDeleteWe provide best selenium training in Chennai with real time scenarios.For real time training reach us 8122241286 and become experts in selenium.
selenium training in chennai
Thank you for sharing such a valuble information
ReplyDeletesap simple finance online training institute in hyderabad
Great efforts put to publish these kinds of articles that are very useful to know. I’m thoroughly enjoying your blog. And Good comments create great relations. You’re doing an excellent job.keep sharing!!
ReplyDeleteSalesforce Training in Chennai
Salesforce Online Training in Chennai
Salesforce Training in Bangalore
Salesforce Training in Hyderabad
Salesforce training in ameerpet
Salesforce Training in Pune
Salesforce Online Training
Salesforce Training