Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Verb RunAs - no output #86

Open
akozyreva opened this issue Apr 5, 2024 · 0 comments
Open

-Verb RunAs - no output #86

akozyreva opened this issue Apr 5, 2024 · 0 comments

Comments

@akozyreva
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant