Psreadline: "Start-Process -NoNewWindow -FilePath PowerShell" and cursor

Created on 13 Sep 2019  路  7Comments  路  Source: PowerShell/PSReadLine

PS version: 5.1.17763.592
PSReadline version: 2.0.0-beta2
os: 10.0.17763.1 (WinBuild.160101.0800)
PS file version: 10.0.17763.1 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 3000


Inkedcursor_LI


(Turkish)
"Start-Process -NoNewWindow -FilePath PowerShell " sorunlu bir koddur. 脟眉nk眉 bu komutu kullan谋rsan谋z imle莽 sabit kalmaz. Powershell'de bu komut girildiyse, komut yaz谋l谋rken ve imle莽 yukar谋 ve a艧a臒谋 hareket eder.

(English)
"Start-Process -NoNewWindow -FilePath PowerShell " is problemly code. Because if use this command then cursor is'nt stable. if this command been entered at the powershell, while command been write and cursor move up and down.

Most helpful comment

I forgot to mention - when I've seen this, it was surprising, as in, not likely me being foolish. I likely hit Ctrl+c when running some script (probably a batch file, not PowerShell).

Maybe it doesn't come up often, but if there is a good solution, it would be helpful.

All 7 comments

I've hit this before but never tracked down what is going on. Very annoying and hard to get out of without closing the window.

Start-Process -NoNewWindow starts an ADDITIONAL process and connects it to the same window, but it does not 'pause' the original process, so now they are both running in the same window at the same time, both are accepting input and producing output, but since PSReadLine forces the cursor to where it believes it should be, you see the cursor move around depending on which process successfully read the input first. Start-Process -NoNewWindow should only be used by non-interactive background processes.

The two processes also take turns accepting input which makes it super fun to type exit.

I think this is expected behavior, even if it is very disorienting to run into. If you really want a new interactive session in the same window just type powershell or add -Wait. Either way I'm not sure what PSRL could do differently here.

I forgot to mention - when I've seen this, it was surprising, as in, not likely me being foolish. I likely hit Ctrl+c when running some script (probably a batch file, not PowerShell).

Maybe it doesn't come up often, but if there is a good solution, it would be helpful.

Example ,"Start-Process -NoNewWindow cmd" . I expect that Powershell works at the background and cmd works at the foreground. Maybe the opposite. In reality, two program works same window at the foreground. I think, this is a problem that especially interactive processes.

If you want to run a task as a background process, you should consider Start-Job, or a more elaborate configuration for Start-Process. Start-Process is working much like spawn would. Unless you specify new stdin, stdout and stderr, the new process always inherits these from the parent process, which is effectively what you get when you use NoNewWindow.

Or consider Start-Process -WindowStyle Hidden

Was this page helpful?
0 / 5 - 0 ratings