Computing.Net > Forums > Programming > Prompting for userinput

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Prompting for userinput

Reply to Message Icon

Name: nagendraG
Date: June 19, 2008 at 13:13:18 Pacific
OS: xp
CPU/Ram: intel
Product: 2006
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: toast (by NoIdea)
Date: June 20, 2008 at 01:28:32 Pacific
Reply:

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


0

Response Number 2
Name: Shr0Om
Date: June 21, 2008 at 12:19:43 Pacific
Reply:

@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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Compare file names in bat... Batch del files and folde...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Prompting for userinput

Batch Extract Text Lines One By One www.computing.net/answers/programming/batch-extract-text-lines-one-by-one/16093.html

Prompt for Variable in Batch File www.computing.net/answers/programming/prompt-for-variable-in-batch-file/12508.html

Access: Prompting for dates www.computing.net/answers/programming/access-prompting-for-dates/7780.html