I have a batch script that continuously pings an address and I want a way to cancel the pinging but not terminate the whole script (alternative to ctrl^C).


Simple. You use CTRL-C as you normally would.

When you do this inside a batch script, you'll get a question ^CTerminate batch job (Y/N)?

If you enter a N here, the ping ends, but the batchfile continues.

  • My problem was that once I entered N, it ended the ping but since I had a loop command it kept restarting the ping. So I simply added a command the the beginning of the script so that I had control over the loop continuing or not. Thank you.
    – Cornbeetle
    Jul 17 '15 at 18:29
  • Ah, but your question did not mention that, so I couldn't know. :)
    – LPChip
    Jul 17 '15 at 19:03
  • No worries, you still made me realize that it would end the ping it's just a matter of what it does next
    – Cornbeetle
    Jul 17 '15 at 19:16
  • If my answer helped you, feel free to accept it. The answer is correct to your question anyway.
    – LPChip
    Jul 17 '15 at 19:37

You can use -n switch of ping to specify the amount of requests to send or use Ctrl+Breakto pause to see statistics without terminating the command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.