1.

Solve : Input?

Answer»

This is probably very simple. I have creaed a batch file that will simply map a person to their personal drive and a office shared drive.

But I want to modify the file so the user is prompted for the ring code for the their site. Then take the variable and plug it into the command to connect to the drives. (That I tink I can do. Just can't find how you add a prompt for the user to input a ring code.) ThanksWhen you need to set a variable that is input by the user, you would enter into the script...

set [highlight]/p[/highlight] MyVariable=Please enter in the required variable:

TIP: type 'help set' from the command prompt will also provide details.

If you ECHO the variable %MyVariable% afterwards, it will DISPLAY the text ENTERED.

Example:
C:\>test

... This is a TEST bacth job ...

Please confirm...
Do you wish to continue ? [y/N] :n

You have chosen NOT to continue.

Ending Script...

C:\>type test.bat
@echo off

@echo.
@echo ... This is a TEST bacth job ...
@echo.
@echo Please confirm...
set /p SQLContinue= Do you wish to continue ? [y/N] :

IF /I "%SQLContinue%" NEQ "Y" (

@echo.
@echo You have chosen NOT to continue.
@echo.
@echo Ending Script...
@echo.

sleep 5

GOTO :FinishRun

)

@echo.
@echo End of Script (anyways).

:FinishRun

:EOF
C:\>
Hope that has been of some help.The previous example, and my example both assume you are running this from a command prompt under Windows 2000/XP/2003. Here is some more simple code:
Code: [Select]@echo off
set /p RingCode=Please enter your ring code:
echo The ring code entered was %RingCode%Just in case you're not running XP/2000/2003, answer.com and input.com can be used to prompt for input. (Google for them). Both are little assembler programs that work by setting an environment variable to the value you're prompted for. You can then query the variable in your batch file.

Good luck. 8-)



Discussion

No Comment Found