使用Java执行cmd命令

时间:2015-09-09 18:48:17

标签: java cmd tshark

我正在尝试运行2 cmd个命令,以便从tshark启动cmd。 能否帮我理解为什么这段代码不起作用?

    Process p = Runtime.getRuntime().exec("cmd.exe");

    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
    writer.write("cd C:/Program Files/Wireshark");
    writer.flush();

    writer.write("tshark.exe -i 1 -p -a duration:60 -w C:/Users/User/Desktop/AutomatedProtocolsPcapsCreator/CreatedPcaps/fileName.pcap");
    writer.flush();

0 个答案:

没有答案