-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
Hello! I need to execute specific powershell command in Java as admin. It works fine, but doesn't return any output. This is my code:
static void runPowerShellScript(){
try (PowerShell powerShell = PowerShell.openSession("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" )) {
PowerShellResponse response = powerShell.executeCommand("Start-Process -FilePath \"powershell\" -Verb RunAs -ArgumentList 'dir'");
System.out.println("Script output:" + response.getCommandOutput());
} catch(PowerShellNotAvailableException ex) {
System.out.println(ex);
}
}
Any ideas, how I can catch output from it?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels