Question:
I’ve searched but did not find any answer.
The task is register one dll using Powershell ps1, followed by other lines of scripts. I don’t want to be interrupted by the dialog, so added the /s
parameter. But now the result information is ignored, no matter succeed or fail.
I want the result displayed in console. But how?
Answer:
Launch regsvr32.exe /s
with Start-Process -PassThru
and inspect the ExitCode
property:
1 2 3 4 5 6 7 |
$regsvrp = Start-Process regsvr32.exe -ArgumentList "/s C:\path\to\your.dll" -PassThru $regsvrp.WaitForExit(5000) # Wait (up to) 5 seconds if($regsvrp.ExitCode -ne 0) { Write-Warning "regsvr32 exited with error $($regsvrp.ExitCode)" } |