Search code examples
processcmdwait

Start /WAIT Program.bat


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)

Solution

  • 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?