0
PowerShell 명령을 실행하는 Java 프로그램을 작성했습니다.Java 프로그램에서 VMWare PowerShell 명령 실행
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PowerShellCommand {
public static void main(String[] args) throws IOException {
String command = "powershell.exe your command";
// Getting the version
String command = "powershell.exe $PSVersionTable.PSVersion";
// Executing the command
Process powerShellProcess = Runtime.getRuntime().exec(command);
// Getting the results
powerShellProcess.getOutputStream().close();
String line;
System.out.println("Standard Output:");
BufferedReader stdout = new BufferedReader(new InputStreamReader(
powerShellProcess.getInputStream()));
while ((line = stdout.readLine()) != null) {
System.out.println(line);
}
stdout.close();
System.out.println("Standard Error:");
BufferedReader stderr = new BufferedReader(new InputStreamReader(
powerShellProcess.getErrorStream()));
while ((line = stderr.readLine()) != null) {
System.out.println(line);
}
stderr.close();
System.out.println("Done");
}
}
내가하고 싶은 것은 : 대신 내가 코드가 VM웨어에서 실행되는 윈도우 서버 PowerShell에서 명령을 실행하게 할 로컬 PowerShell에서 명령을 실행 여기에 내 코드? 코드를 어떻게 수정해야합니까?
나는 나에게 말했다. 그러나이 오류가 나타납니다. 원격 서버 192.168.2.3에 연결하지 못했습니다. 다음 오류 메시지와 함께 실패했습니다. 액세스가 거부되었습니다. 자세한 내용은 about_Remote_Troubleshooting 도움말 항목을 참조하십시오. + CategoryInfo : OpenError : (192.168.2.3:String) [], PSRemotingTransportException + FullyQualifiedErrorId : AccessDenied, PSSessionStateBroken -------------------------- ---------------------------------- 나는 많은 연구를했으나 이것을 처리 할 수있는 어떤 것도 찾지 못했습니다. –
"about_Remote_Troubleshooting 도움말 항목"을 보았습니까? –