Excallypurr
Excallypurr

Reputation: 319

Powershell ISE breaks when using CMD /C Pause

I'm newer to PowerShell, transitioning from batch, so forgive me if I make a stupid mistake. I really like using Powershell ISE. But with the current script I'm trying to run, I use the cmd /c pause | Out-Nul command and it breaks ISE by not allowing me to continue any further.

I was trying for a long time to find some way to pause but not show output from the command and I found the cmd /c pause command. I can run it fine in a normal PowerShell prompt but ISE just isn't having it.

Anyone have any ideas why this happens or a better alternative to cmd /c pause Out-Nul? Thanks and any advice is more than welcome!

Upvotes: 1

Views: 338

Answers (1)

Señor CMasMas
Señor CMasMas

Reputation: 5108

  1. Powershell ISE doesn't redirect STDIN (which pause needs).
  2. Shelling out to cmd for the pause command is unneeded.

See this post for more info on the ISE not being able to take stdin. You won't find your specific issue but the problem is the EXACT same problem.

On that page, you will also find a better/native way to do "pause" from powershell... (aka [System.Console]::ReadKey($false) )

Upvotes: 3

Related Questions