10

I find that if I start a process by start-process in powershell , the new window will be closed automatically after execution complete , is it possible to keep it waiting for my further command to close?

3 Answers 3

11

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

Sign up to request clarification or add additional context in comments.

Comments

6

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

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

Comments

1

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 runAs
exit

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.