Write-Host "Executando o programa..."

$exe = Join-Path $PSScriptRoot "epsonEconomiaPapelTM.exe"
$parametros = "192.168.0.8", "-log"

$processo = Start-Process `
    -FilePath $exe `
    -ArgumentList $parametros `
    -Wait `
    -PassThru

if ($processo.ExitCode -eq 0) {
    Write-Host "Execucao com SUCESSO (retorno 0)"
    exit 0
} else {
    Write-Host "ERRO na execucao (retorno $($processo.ExitCode))"
    exit 1
}
