Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
HI All,
I have a .Bat script,which gets the file from source system to target system.
I want to add some lines which will prompt for the user input....say after it gets the file from source to target it has to prompt
check the files in server\dir\abc and enable the recovery (y/n)-
the user should type y or n...
what ever he types either Y or n it has to continue the remaining script.The prompting is just to inform the user that recovery should be enabled..
how can i add this in my .Bat script
Thanks,
NagendreG

This is my way:-
Change the ?????? for your statements and GOTO's:Loop
echo.
echo ????????
echo.
echo ?????????
echo.
:: SET /P prompts for input and sets the variable
:: to whatever the user types
SET Choice=
SET /P Choice= TYPE THE LETTER AND PRESS ENTER: -^>
cls
IF NOT '%Choice%'=='' SET Choice=%Choice%
:: /I makes the IF comparison case-insensitive
IF /I '%Choice%'=='y' GOTO :?????
IF /I '%Choice%'=='n' GOTO :???????
echo "%Choice%" IS NOT VALID. PLEASE TRY AGAIN
echo.
GOTO :Loop
cls

@echo off
:start
cls
set /p input=Check the files in server\dir\abc and enable the recovery (y/n)?:
if /i "%input%" equ "y" goto :RecoveryEnabled
if /i "%input%" equ "n" goto :next
echo Invalid choice & pause & goto start:RecoveryEnabled
echo Recovery enabled
::Enable recovery commands here
pause
exit:next
echo Recovery not enabled
pause
exit

![]() |
Compare file names in bat...
|
Batch del files and folde...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |