1

I am trying to write a batch file that starts another batch file, waits for that batch file to complete its job, and then continue once that other batch file has exited. However, when I manually close the batch file launched by the first batch file, it comes up with a prompt saying:

^CTerminate batch job (Y/N)?

Is there a way to automatically select 'N', because it needs to delete some temporary files on exit.


Purpose/Premise of Script: To be able to remove a flash drive and lock the station (hence copying files to external source).

Summary of Script:

  1. Program Copies files to %homedrive%
  2. Program launches another script (one of the files copied to homedrive)
  3. After that program quits, it deletes the copied files

Solutions Tried:

  • Different command switches inside of START /WAIT +/I +/B (Adding /I or /B did not produce anything useful)
  • Using /C and /K switches after the START /WAIT program.bat +/C +/K (had no affect)

2 Answers 2

3

Well, you could use echo n | program.bat to automatically respond n to ^CTerminate batch job (Y/N)?, but an easy way to fool this method is to hit and keep pressed [Ctrl]-C.

There simply is no reliable way to disable the interruption of any program (much less a batch file). What stops the user from just closing the window?

Sign up to request clarification or add additional context in comments.

1 Comment

OMG! It worked. I changed my code from start /WAIT program.bat into: start /WAIT program.bat | echo n works like a charm! thank you so much for the tip!
1

You would want a command like this:

start /wait program.bat|echo n>nul 

">nul" will hide the "n" that shows up afterwards. But there doesn't seem to be a way to stop "^C" from showing up.

1 Comment

Seems there is a way to silence the ^C : ` start /wait program.bat 2>nul | echo n > nul`

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.