Title: Start-Process does not populate the process object's exit code with NoNewWindow switch · Issue #20400 · PowerShell/PowerShell · GitHub
Open Graph Title: Start-Process does not populate the process object's exit code with NoNewWindow switch · Issue #20400 · PowerShell/PowerShell
X Title: Start-Process does not populate the process object's exit code with NoNewWindow switch · Issue #20400 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/20400
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Start-Process does not populate the process object's exit code with NoNewWindow switch","articleBody":"### Prerequisites\n\n- [X] Write a descriptive title.\n- [x] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [X] Search the existing issues.\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\nI noticed that the `Start-Process` cmdlet sometimes does not populate the `ExitCode` property in the output, I believe it should.\r\nThis happed at least when `-PassThru`, `-Wait`, and `-NoNewWindow` switches are provided. `-NoNewWindow` seems to be the reason, since the exit code is available without it.\r\n\r\n\r\n## Steps to reproduce\r\nYou can see this behavior with this simple test script\r\n```\r\nSet-Content -Value \"exit 1\" -Path script.ps1\r\n$p = start-process \"pwsh\" script.ps1 -PassThru -NoNewWindow -Wait\r\n$p.ExitCode # Should output: 1\r\n$p = start-process \"pwsh\" script.ps1 -PassThru -Wait\r\n$p.ExitCode # Outputs: 1\r\n```\r\n\n\n### Expected behavior\n\n```console\nPS C:\\\u003e set-content -Value \"exit 1\" -Path script.ps1\r\nPS C:\\\u003e $p = start-process \"pwsh\" script.ps1 -PassThru -NoNewWindow -Wait\r\nPS C:\\\u003e $p.ExitCode\r\n1\r\nPS C:\\\u003e $p = start-process \"pwsh\" script.ps1 -PassThru -Wait\r\nPS C:\\\u003e $p.ExitCode\r\n1\n```\n\n\n### Actual behavior\n\n```console\nPS C:\\\u003e set-content -Value \"exit 1\" -Path script.ps1\r\nPS C:\\\u003e $p = start-process \"pwsh\" script.ps1 -PassThru -NoNewWindow -Wait\r\nPS C:\\\u003e $p.ExitCode\r\nPS C:\\\u003e $p = start-process \"pwsh\" script.ps1 -PassThru -Wait\r\nPS C:\\\u003e $p.ExitCode\r\n1\n```\n\n\n### Error details\n\n_No response_\n\n### Environment data\n\n```powershell\nPS C:\\\u003e $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 7.4.0-preview.5\r\nPSEdition Core\r\nGitCommitId 7.4.0-preview.5\r\nOS Microsoft Windows 10.0.20348\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\n```\n\n\n### Visuals\n\n_No response_","author":{"url":"https://github.com/unlikelier","@type":"Person","name":"unlikelier"},"datePublished":"2023-09-29T10:48:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":21},"url":"https://github.com/20400/PowerShell/issues/20400"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6df9f4d0-b627-60fe-8ecf-6fe338d3da43 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD7A:2D0EDC:75F48B:AA6F0B:6A5494A2 |
| html-safe-nonce | 8be0cf010ac34acd117378b77d3d3224d28435307921e9bd3ba1cc8b407a69d0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDdBOjJEMEVEQzo3NUY0OEI6QUE2RjBCOjZBNTQ5NEEyIiwidmlzaXRvcl9pZCI6IjM2OTE5MzE3ODYzOTkzMDUzMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5fa432b6e614be7150db4ad19837716af0b32db8e91160cd302f69a1c808bd80 |
| hovercard-subject-tag | issue:1919048699 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/20400/issue_layout |
| twitter:image | https://opengraph.githubassets.com/173636b5f6642391231dc96ead29b5879ac56b643a0250da4f0de4af0e1ab0ee/PowerShell/PowerShell/issues/20400 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/173636b5f6642391231dc96ead29b5879ac56b643a0250da4f0de4af0e1ab0ee/PowerShell/PowerShell/issues/20400 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | unlikelier |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f8cfff6384f62259baea531c7f58bc7040f8dd92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width