Invoke an exe from PowerShell and get feedback on success or failure

后端 未结 2 800
渐次进展
渐次进展 2020-12-03 09:22

How can I run an executable in PowerShell and through an if statement determine whether it succeeded or failed?

More specifically I\'m trying to get devenv.exe to bu

2条回答
  •  無奈伤痛
    2020-12-03 10:09

    .\YOUREXE.exe
    if($LASTEXITCODE -eq 0)
    {
        Write-Host "The last PS command executed successfully"
    } 
    else 
    {
        Write-Host "The last PS command failed"
    }
    

提交回复
热议问题