JSI Tip 2545. How can I get a batch file to prompt me for parameters in Windows 2000?


In Windows NT, we had to use tip 0323 to accomplish this.

In windows 2000, you can use the

SET /P variable=\[promptString\]

"The /P switch allows you to set the value of a variable to a line of input
entered by the user.  Displays the specified promptString before reading
the line of input.  The promptString can be empty."
Here is a silly little example:
@echo off
setlocal
set OK=N
:again
set /p user=Please enter your User Name or END.     
if /i \[%user%\]

\[END\] endlocal&goto end if \[%user%\]

\[\] goto again for /f "Tokens=*" %%i in ('net user "%user%" /domain') do call :parse "%%i" If "%OK%"

"N" goto again set /p xxx=Press any key to exit. endlocal goto end :parse set ustr=%1 if not "%ustr:~1,9%"

"Full Name" goto end set ustr=%ustr:"=% set ustr=%ustr:Full Name =% @echo Thank you %ustr% set OK=Y :end

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish