Execute Powershell script using java

江枫思渺然 提交于 2020-01-05 05:56:21

问题


I want to execute powershell cmdlets using java . Is there any way i can implement this? I tried using Runtime and exec commands but output window hangs in between.


回答1:


It's easier to use the newer ProcessBuilder class. Runtime.exec has several pitfalls that you need to remember, in order for things to work correctly. For example you need to make sure that the input and outputstreams to the process are handled correctly.

I suggest you google for an example on using ProcessBuilder.



来源:https://stackoverflow.com/questions/17467676/execute-powershell-script-using-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!