Web Development

General discussion


Batch file programming

By zeealen247 ·
How do I create a batch file to do something like this:
@echo off
echo About to FORMAT drive A...
echo Proceed or Abort P/A [where p =Proceed and A=Abort]-the bracket and its content not included please.
Something like that... so that the user is given a set of predefined characters to type to effect some actions. like Procced or Abort P/A
And when the user strikes the "P" key the computer should proceed and when the user does the opposite the computer should Abort the operation.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by sgt_shultz In reply to Batch file programming

you can do as you wish but it is complicated as you have to declare and set and compare to variables. can you work with the simple pause command? if you put in the pause it will stop the execution of the batch file until the user presses a key. e.g.:
echo the contents of the floppy disk in A are about to be obliterated forever! if you have the stomach for it
@echo pause

Collapse -

by ananthap In reply to Batch file programming

DOS (> 5) has a command called CHOICE.com which I believe does exactly what you want. If yyour example, if you press any other key also, it wont work.

The usege is someting like CHOICE [message] [responses].
Follow this by ERRORLEVEL ..

FYI, CHOICE by itself has defaults of Y or N.



Collapse -

by zeealen247 In reply to Batch file programming

Well, I was the one who posed the question earlier. I am glad and grateful for the help rendered me my those who offered their own answers. However in the course of time, through research and the helpof God I have been able to get the answer to the question I asked sometime ago. Refer Below:

@echo off
If "%1"=="P" goto Proceed
If "%1"=="A" got Abort
echo About to Format drive A.Proceed/Abort(P/A)?
echo @%0 P > P.bat
echo @%0 A > A.bat
goto end

Echo Commencing the Formattting Process...
goto end

Echo Aborting the Formatting Process...

Related Discussions

Related Forums