Stop Powershell from exiting

后端 未结 8 1894
傲寒
傲寒 2021-02-05 06:01

I know that there is that little -noexit switch for PowerShell.

Is there anyway of staying in the shell without using that switch?

In other words, I

8条回答
  •  天涯浪人
    2021-02-05 06:52

    You basically have 3 options to prevent the PowerShell Console window from closing, that I describe in more detail on my blog post.

    1. One-time Fix: Run your script from the PowerShell Console, or launch the PowerShell process using the -NoExit switch. e.g. PowerShell -NoExit "C:\SomeFolder\SomeScript.ps1"
    2. Per-script Fix: Add a prompt for input to the end of your script file. e.g. Read-Host -Prompt "Press Enter to exit"
    3. Global Fix: Change your registry key to always leave the PowerShell Console window open after the script finishes running.

    See my blog for more information on which registry keys to modify.

    Sounds like you are looking for option #1 or #3.

提交回复
热议问题