- Notifications
You must be signed in to change notification settings - Fork8.1k
Open
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on thelatest released version
- Search the existing issues.
- Refer to theFAQ.
- Refer toDifferences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Note: This is an edge case; if correcting the inconsistency discussed below is deemed not worth the effort, it should at least be documented.
- On Windows, GUI-subsystem applications execute asynchronously by default.
- Piping (
|) them to another command makes the call synchronous and also populates$LASTEXITCODE - By contrast, applying aredirection (
>) surprisingly doesnot do that.
The piping technique is a useful (albeit obscure) shortcut to invoking GUI applications synchronously (albeit limited to GUI applications that do not delegate to another process on startup);>$null would make it more concise.
msiexec.exe|Out-Null"`$LASTEXITCODE after:$LASTEXITCODE"$global:LASTEXITCODE=0msiexec.exe>$null"`$LASTEXITCODE after:$LASTEXITCODE"
Expected behavior
Both invocations ofmsiexec.exe should be synchronous (blocking) and populate$LASTEXITCODE
Actual behavior
Only the first invocation behaves as expected.
Error details
Environment data
PowerShell7.6.0-preview.5 on Windows.
Visuals
No response