Home > Mobile >  How to terminate a terminal session in a ps1 script
How to terminate a terminal session in a ps1 script

Time:03-05

How can I terminate a terminal/PowerShell window from a .ps1 script? I would like it to work the way exit in command line works, but when I put that in a PowerShell script it only terminates the script.

CodePudding user response:

Environment.Exit() will terminate the whole process:

# replace 0 with a non-0 error code if you want to indicate some sort of failure
[Environment]::Exit(0)
  • Related