I am using a silent installation command to install software. I am running this command from PowerShell 3.0.
$silentInstall = C:\\Users\\Admin\\Documents\\Se
It depends on how the EXE file runs - sometimes it will kick off a separate process and return immediately, and in such cases this usually works -
$p = Start-Process -FilePath -ArgumentList -Wait -NoNewWindow -PassThru
$p.ExitCode
Otherwise this usually works -
&
$LASTEXITCODE
Or sometimes this -
& cmd.exe /c
$LASTEXITCODE