Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm aware that I can interrupt a running batch file witch Crtl-C, and then continue the execution.

However, is it possible to execute a command in the batch file's cmd environment while the batch is paused?

For example, I might want to pause a running batch, change some variables it has SET previously, then continue the execution.

share|improve this question
add lines with modifications (i.e. set new value to the variable) after pause and continue the batch – jet Sep 2 '12 at 19:34
such a simple solution! :) unfortunately, can't select comment as answer – vedran Sep 2 '12 at 22:01
@jet: How would one continue execution of the batch file where it left off (i.e. right after the pause command)? – martineau Sep 3 '12 at 0:47
@vedran: I added it as an answer – jet Sep 3 '12 at 1:04
@martineau: before pause, put for example... and then you know... exit and you are back to the batch, maybe there is a better way – jet Sep 3 '12 at 1:04
up vote 1 down vote accepted

Add lines in the batch with modifications (i.e. set new value to the variable) after pause and continue the batch

share|improve this answer

This code will allow to execute arbitrary commands from within batch context: Put it a batch file and play with it.

@echo off

  set cmd=
  set /p "cmd=Please give command, empty line to finish "
  if defined cmd (
    call %cmd%
    goto loop

To finish executing commands just hit Enter

To use it in your batch, just insert a line with call to above:

do stuff 
do more stuff

call interrupt_me.bat

do even more stuff

If you wonder why there is a call %cmd% instead of straight %cmd% - it allows to expand variables passed so commands like echo %comspec% work properly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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