问题
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