1

I put this code into a .bat script to run a file:

  powershell -NoProfile -ExecutionPolicy Bypass .\abc.ps1"

When the script finishes the window closes and I can't see the output. How can I make the window stay open?

4
  • Run your script directly in PowerShell. Then you don't need a batch file. Commented Jul 24, 2015 at 20:42
  • Why do you run a PS script in cmd? Commented Jul 24, 2015 at 20:45
  • I'd add pause on a new line. Commented Jul 24, 2015 at 20:57
  • My guess is that the point of running it in a batch file is to control execution policy without setting it in advance on the machine. Commented Jul 25, 2015 at 20:25

1 Answer 1

1

Depends on what you want left in the window. Do you want a command prompt? If so use:

cmd /k powershell -NoProfile -ExecutionPolicy Bypass .\abc.ps1

Do you want a powershell window?

powershell -NoExit -NoProfile -ExecutionPolicy Bypass .\abc.ps1
Sign up to request clarification or add additional context in comments.

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.