Skip to content

Can't get output if there is an error #19

Open

Description

@vlad8x8

Some commands can return error and some output.
Example: Get-Process chrome,Tuupertunut returns an error about Tuupertunut and a list of chrome processes.
PowerShellLibJava throws PowerShellExecutionException and doesn't provide access to the list of chrome processes

Activity

  1. Tuupertunut commented on Feb 7, 2023

    @Tuupertunut
    Owner

    Yes, the library has been designed so that it throws an error if anything was printed to stderr. This works for most use cases but sometimes it could be useful to get output from stdout even if there is an error. However it is very unlikely that I would ever update this library to support that use case.

    You can circumvent this limitation by wrapping the PowerShell code in PowerShell's try-catch and handling the errors yourself, or you could edit the library code to give you access to stdout output.

  2. vlad8x8 commented on Feb 7, 2023

    @vlad8x8
    Author

    Hi @Tuupertunut . Thank you for reply.
    I decided to use basic java Runtime.getRuntime().exec("powershell.exe " + command) without libraries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions