Java stuck in infinite loop executing a wmic command on Windows Server 2003

后端 未结 2 1249
伪装坚强ぢ
伪装坚强ぢ 2021-01-23 00:29

I\'m trying to get a list of running processes and their file paths on a Windows Server 2003 machine. I\'m using the following code to try and do that:

protected         


        
2条回答
  •  鱼传尺愫
    2021-01-23 01:28

    You will need to get and close your OutputStream before getting and using your InputStream. That will confirm to the process that you've started that you have finished sending input (in this case, no input) to the process.

    p.getOutputStream().close();
    

    Remember that on the Process object, getInputStream() input comes from the output stream of the process, and getOutputStream() output goes to the input stream of the process.

提交回复
热议问题