start-process in Powershell closes Window automatically after execution is complete start-process in Powershell closes Window automatically after execution is complete powershell powershell

start-process in Powershell closes Window automatically after execution is complete


Try passing -noexit as a parameter to powershell.exe when you start it.


you mean start a command prompt? right? if so, hope following script could be helpful

Start-Process cmd -ArgumentList '/c','echo test' # auto closeStart-Process cmd -ArgumentList '/k','echo test' # keep waiting


I've managed to get what I need (open powershell as administrator in a specific location), assembling this way:

Start-Process powershell -ArgumentList "-noexit -command ""& {Set-Location D:\YourPath}""" -Verb runAsexit

Start-process: will start powershell with Args, to not exit and open at a specific location and will call administrative privileges.Exit> this will exit the first window that will open.