1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Powershell - Getting Exitcode From A Command

Discussion in 'Windows 7' started by gw1500se, 2016/05/15.

  1. 2016/05/15
    gw1500se

    gw1500se Well-Known Member Thread Starter

    Joined:
    2003/01/10
    Messages:
    442
    Likes Received:
    0
    I have a powershell script in which I want to run a python snippet and get the exit code (either 1 0r 0). I tried several iterations and nothing seems to work.

    $py= "import sys`ntry:`n import wx`nexcept:`n sys.exit(1)`nsys.exit(0) "
    $result=Start-Process -FilePath "$pyPath\python.exe" -ArgumentList "-c ` "$py`" "
    Write-Host "Exit code was " $result.ExitCode

    The output is:

    Exit code was

    How do I get the exit code from this command? TIA.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.