Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start PowerShell with -NoExit not working

Tags:

powershell

Need to launch several jobs in PowerShell, but they should be in different sessions. So to launch one, one could use:

Start-Process powershell -ArgumentList "-command &{Get-Process}","-noexit","-noprofile"

But the new window closes as soon as the command finishes. Even though I'm using -NoExit parameter. Acording to this article and this question, this should work. Even tried to block the window, by waiting for an user input, but it just closes.

like image 345
Syphirint Avatar asked Feb 06 '23 10:02

Syphirint


1 Answers

While the command parameters are named, position is still critical (see PowerShell.exe /?):

Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{Get-Process}"
like image 60
Chris Dent Avatar answered Feb 08 '23 23:02

Chris Dent