Alex Rivera | Logout

How can I make an "are you sure" prompt in a Windows batch file?

Asked 2009-11-25T04:08:46.273
139

I have a batch file that automates copying a bunch of files from one place to the other and back for me. Only thing is as much as it helps me I keep accidentally selecting that command off my command buffer and mass overwriting uncommitted changes.

What code would I need for my .bat file to make it output "Are you sure?", and make me type Y before it ran the rest of the file?

If anything other than Y is typed, it should exit execution on that line.

When I call exit, it closes cmd.exe which is not what I want.

Edit
Report

1 Answer

45

try the CHOICE command, e.g.

CHOICE /C YNC /M "Press Y for Yes, N for No or C for Cancel."
answered 2009-11-25T04:12:50.247

Your Answer