Java----invoke DOS command for Windows and Echo/start and close Appium

Source: Internet
Author: User
Tags appium

/** *  java calls the Windows DOS command  *   implements the ipconfig command that invokes windows, and then outputs the output information to the console via IO stream.  *   Implement start Appium service  *   implement close Appium service  */public class Doc {     public static void main (String[] args)  throws exception {          String cmd =  "ping www.baidu.com";          String cmd1=  "Cmd /c appium";            string cmd2= "taskkill /F /IM  Node.exe ";         //          dosstartandprintresult (CMD2);//         thread.sleep (          dosstartandprintresult (CMD1);        &nbSp; thread.sleep (         dosstartandprintresult) (CMD2) ;            }         /** passes in a command, executes a DOS command, and echoes back */    public static void  dosstartandprintresult  (String cmd) {                 try {             runtime rt = runtime.getruntime (); //  Get runtime system                process proc = rt.exec (cmd);//execute command             bufferedreader br = new  bufferedreader (New inputstreamreader (Proc.getinputstream (),  charset.forname ("GBK"));// Solve the problem of garbled printing results             //echo DOS command results after execution              String line = null;               while  ((Line = br.readline ())  != null)  { //  Print out the results of the command execution                    system.out.println (line);               }          } catch  (ioexception e )  {            e.printstacktrace ();         }     }         }=================== start appium** Execution Results ===========================[appium] welcome to  appium v1.6.5[appium]&nbsp appium rest http interface listener started on 0.0.0.0:4723================ ===ping Baidu * * Implementation Results =========================== is  Ping www.a.shifen.com [220.181.112.244]  has  32  bytes of data: Reply from  220.181.112.244 :  byte =32  time =2ms ttl=55 from   220.181.112.244  reply:  byte =32  time =2ms ttl=55 reply from  220.181.112.244 :  bytes =32  Time =4ms ttl=55 from  220.181.112.244  reply:  byte =32  time =1ms ttl=55220.181.112.244   Ping  Statistics:     Packet:  sent  = 4, received  = 4, lost  = 0   (0%  lost), estimated time to round trip (in milliseconds):     shortest  = 1ms, longest  = 4ms, average  =  2ms    =================== shutdown appium** Execution result =========================== successful:  terminated process   "Node.exe", its  PID  is  42808.



Java----invoke DOS command for Windows and Echo/start and close Appium

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.