Repository navigation
Closed
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-BugIssue has been identified as a bug in the productOS-LinuxOS-WindowsOS-macOSResolution-No ActivityIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-Interactive-Consolethe console experience
Description
Steps to reproduce
Start-Process -NoNewWindow powershell
Expected behavior
Run process in a new window
Actual behavior
Run process in the same window, but UX is broken
PS /Users/vors> Start-Process -NoNewWindow powershell
PS /Users/vors> 14;1Rl
14pyright (C) 2016 Microsoft Corporation. All rights reserved.
1Rl : The term '1Rl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:4
+ 14;1Rl
+ ~~~
+ CategoryInfo : ObjectNotFound: (1Rl:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS /Users/vors> ^Dlssaad
Environment data
Repros on OS X, Linux and Windows
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.10032.0
PSEdition PowerShellCore
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.7
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1 Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-BugIssue has been identified as a bug in the productOS-LinuxOS-WindowsOS-macOSResolution-No ActivityIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-Interactive-Consolethe console experience
Activity
0xfeeddeadbeef commentedon Apr 13, 2017
sergei (@vors) Expected behavior is not quite correct. According to
Get-Help Start-Process:it should start in the current console window.
However, UX being broken is still true, - it seems that both parent and child powershell.exe processes are competing for user input. This is my attempt to type
$PSVersionTable:joeyaiello commentedon May 23, 2017
Yeah, can confirm this is still broken.
florinciubotariu commentedon Aug 2, 2017
Can confirm it is still reproducible.
mklement0 commentedon Aug 7, 2017
Definitely broken, but It is worth noting that
Start-Process -NoNewWindow powershelldoesn't make much sense, given that it amounts to running an interactive shell asynchronously in the current terminal (which results in two shells competing for input, as Giorgi Chakhidze (@0xfeeddeadbeef)'s experience suggests).Adding
-Wait-Start-Process -Wait -NoNewWindow powershell- works properly, but there's no good reason to use it, given that just invokingpowershelldirectly is not only simpler (it implicitly runs synchronously in the current terminal), but is also properly integrated with the current session's input/output streams, unlike aStart-Processcall.-NoNewWindowis really only useful in very limited circumstances:-RedirectStandardOutput/-RedirectStandardErrorIt is a poor substitute for using a job to launch a console application in the background, which gives you much better control.
Unless I'm missing other use cases for
-NoNewWindow, it may be a candidate for deprecation.vors commentedon Aug 7, 2017
True, counting the number of negatives is hard :D
If I recall correctly, the reason I opened the issue is the there is mismatch in behavior and on core powershell it's implicit
NoNewWindow.mklement0 commentedon Aug 7, 2017
sergei (@vors): It may be time to decide the fate / behavior of
Start-Processon Unix platforms: please see #4521.vors commentedon Feb 20, 2018
How about making
NoNewWindowa no-op on unix?12 remaining items
mklement0 commentedon Dec 6, 2018
There is no reason to involve
Start-Processat all if you want to run a console/terminal-based application synchronously: not only is direct invocation simpler, only the latter guarantees that the invoked program's output streams are connected to PowerShell's.Start-Processis asynchronous by default; that's what the standard verb in its name implies, and I don't think there should be any exceptions, especially not for use cases that make no sense to begin with.-NoNewWindowin effect is a no-op on Unix-like platforms, and it makes sense to document it as such.Yes, that means that someone can shoot themselves in the foot with something like
Start-Process [-NoNewWindow] bashon Unix, but to me that's still preferable to special-casing behavior.Sensible use cases for
Start-Processon Unix are very limited compared to Windows; I've tried to summarize them here - integration into the docs is pending.SteveL-MSFT commentedon Dec 19, 2018
Michael Klement (@mklement0) I agree that
Startimplies async and also agree that-NoNewWindowdoesn't make sense on Unix-like platforms. However, it doesn't make sense to continue to allow users to get into this situation. However, I don't see this as a priority to fix as I don't believe it affects a large number of users and I expect they'll learn quickly not to use it again after the first time.mklement0 commentedon Dec 19, 2018
Steve Lee (@SteveL-MSFT):
Yes, which is why I think the problem can be dealt with by simply providing proper guidance in the
Start-Processhelp topic (update: see MicrosoftDocs/PowerShell-Docs#3013):By stating in the
Descriptionsection that-NoNewWindowis invariably implied on Unix-like platforms.By stating in the description of parameter
-NoNewWindow:that (possibly implied)
-NoNewWindowis only relevant to console/terminal-based applications and generally only makes sense in very limited circumstances (to put it differently: typically, there's no need to useStart-Processto invoke console/terminal-based programs):Launch-it-and-forget-it console/terminal-based commands known not to produce output / expect interactive input (if the target program is not console/terminal-based, there's no reason to use
-NoNewWindowto begin with),Console/terminal-based commands that require running with a pristine environment with
-UseNewEnvironment; if such commands happen to produce output / require interactive input, then-Waitmust used, too. (On Windows, if the process with a pristine environment should run in a new window anyway, there's obviously no need for-NoNewWindow.)that not also including
-Waitfor console/terminal-based application will cause them to send output asynchronously / compete for interactive input with the calling session.red8888 commentedon Jun 19, 2020
when using
-NoNewWindowI get this error:This command cannot be run due to the error: %1 is not a valid Win32 application.BouwenMA commentedon Jul 2, 2020
I've come across issues with this today wondering why my Start-Process with -NoNewWindow parameter was seeming to hang until I pressed enter...
As Michael Klement (@mklement0) stated above, I agree that the help topic should be updated. After spending a bit of time with several searches and articles trying to figure out the problem, I finally came across this issue... Noting that one should use "-Wait", or altering the behavior of -NoNewWindow to implicitly wait, would seem to be very helpful. Had it been in the contents of the Start-Process help, I would've known immediately...
For my use case, I've been using Start-Process for running PSExec with various parameters, as I cycle through pushing updates to many servers. But for simplicy, the behavior I'm seeing can be reproduced on all PowerShell versions 5-7.1 I've tried so far like this:
The output will be shown, with the cursor just sitting at the bottom flashing, and only bring back the prompt after I hit enter or up arrow... As long as I append "-Wait" it behaves as desired...
mklement0 commentedon Jul 2, 2020
Thanks, Mathias (@BouwenMA).
Note the pending issue requesting updating of the docs (it's been open since December 2018): MicrosoftDocs/PowerShell-Docs#3013 - if you're up for it, you could try to submit a PR yourself.
Also - in case
ipconfig.exewasn't just a random example - remember that there's generally no good reason to useStart-Processwith console applications such asipconfig.exe(orpsexec), as explained above and as also covered in the linked issue.doctordns commentedon Feb 15, 2022
Trying this in 7.2.1 - the UX is still broken.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.