|
Answer» I would like to have my batch file ASK if I am sure I want to continue before it runs. I very new to batch files but so fare have be able to create one to perform a tedious task.
IF NOT EXIST O:\ARCHIVE\%1\NUL MD O:\ARCHIVE\%1 XCOPY /E F:\ACAD\%1\*.* O:\ARCHIVE\%1 XCOPY /E F:\ADMIN\%1\*.* O:\ARCHIVE\%1 rmdir F:\ACAD\%1 /s rmdir F:\ADMIN\%1 /s
I want to have the batch ask "Are you sure you want to Archive job %1?"
then I can enter "Y" or "N".
Can any one help me do this or point me to an example I can use?very simple, using SET /p to capture user input:
Code: [Select]:start set input= set /p input=Are you sure you want to Archive job %1? if /i %input% equ y goto yes if /i %input% equ n goto no goto start
:yes rem code here exit
:no exit
i haven't tested this code, but under yes. you will PUT your code if they want to, and no... you GET the ideaQuote from: BatchFileBasics on July 28, 2009, 11:17:08 AM very simple, using set /p to capture user input:
i haven't tested this code, but under yes. you will put your code if they want to, and no... you get the idea
If you use EQU and no quotes, what happens when the user just presses ENTER? To AVOID a crash I suggest this change:
Code: [Select]if /i "%input%"=="y" goto yes if /i "%input%"=="n" goto no
|