James
James

Reputation: 25

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:

Upvotes: 1

Views: 3257

Answers (2)

FluorescentGreen5
FluorescentGreen5

Reputation: 947

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.

Upvotes: 1

Dennis
Dennis

Reputation: 14477

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?

Upvotes: 3

Related Questions