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 Answer
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.
3 Comments
sanyam jain
I tried using ProcessBuilder class, but it is able to execute only a single powershell command. I tried passing powershell script file to execute but result is same as Runtime.exec console hangs in between.
crow
This is a good lead, but could be a much better answer with a (minimal) example and more concrete, specific information.
Kayaman
@Kröw Pure shite, the question should be deleted.