Command prompt flashes then disappears windows 7

broken image
broken image

Per-script solutionĪdd a line like this to the end of your script: The other way is to launch the PowerShell process from the Run box (Windows Key + R) or command prompt using the -NoExit switch and passing in the path to the PowerShell file.įor example: PowerShell -NoExit “C:\SomeFolder\MyPowerShellScript.ps1” 2. I show how to do this a bit in this post, as the PowerShell syntax to run a script from the command-line is not straight-forward if you’ve never done it before.

broken image

Open a PowerShell console and manually run the script from the command line. We have 3 solutions to fix this so that the PowerShell console stays open after the script has finished running: 1. If the script gives output that the user wants to see, or if it throws an error, the user won’t have time to read the text. When running a script by double-clicking it, or by right-clicking it and choosing Run With PowerShell or Open With Windows PowerShell, if the script completes very quickly the user will see the PowerShell console appear very briefly and then disappear.

broken image
broken image

I originally included this as a small bonus section at the end of my other post about fixing the issue of not being able to run a PowerShell script whose path contains a space, but thought this deserved its own dedicated post. Keep PowerShell Console Window Open After Script Finishes Running