Я хочу вызвать мою powershell script из java. Это можно сделать. Я попытался использовать следующий код, но поток не закрывается.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class TestPowershell {
public static void main(String[] args) throws IOException
{
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("powershell C:\\testscript.ps1");
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isr);
String line;
while ((line = reader.readLine()) != null)
{
System.out.println(line);
}
reader.close();
proc.getOutputStream().close();
}
}
Вызывает ли java файл powershell script, который выполняет создание удаленного сеанса и выполняет командлеты?
Есть ли у нас поддержка для вызова скриптов powershell в java?
Кто-нибудь мог бы вам помочь в этом.
Ожидает ответа.
Спасибо, rammj