Don't display input

  • Thread starter Thread starter Mr. Novice
  • Start date Start date
M

Mr. Novice

Is there a way to ask a user for information and have it
not display when they enter it in?

I'm wanting to ask them for their password, set it as a
variable and then test that password before using it in
another command that will use that password variable. This
way if the password is incorrect the user can correct it
before getting too far along. If I use set /p and ask them
for the password it will be dispalyed on the screen when
they type it. Is there a way to prevent what's being typed
from being displayed?

Thanks!

Chad
 
Is there a way to ask a user for information and have it
not display when they enter it in?

I'm wanting to ask them for their password, set it as a
variable and then test that password before using it in
another command that will use that password variable. This
way if the password is incorrect the user can correct it
before getting too far along. If I use set /p and ask them
for the password it will be dispalyed on the screen when
they type it. Is there a way to prevent what's being typed
from being displayed?

The CLI I use (4NT) has a command INPUT which provides the parameter
/P for starred password entry:

INPUT [/C /D /E /Ln /N /P /Wn /X] [prompt ] %%varname
prompt: Optional text that is displayed as a prompt
varname: Variable that will hold the user's input
/C(lear buffer) /N(o colors)
/D(igits only) /P(assword)
/E(dit) /W(ait)
/L(ength) /X (no carriage return)

I'm sure there are also single-purpose utilities available for this
sort of thing, e.g. STRINGS.
 
Mr. Novice said:
Thanks Phil!

Herbert Kleebauer posted a few lines that work perfectly!
I'll take your hint and search that google newsgroup from
now on!

Thanks again!

Chad

@echo off
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>in.com
set /p password=Enter password:<nul
for /f "tokens=*" %%i in ('in.com') do set password=%%i
del in.com
echo.
echo The Password is:"%password%"

You're welcome. The main difference is (1) display nothing
when the user types, or (2) display a masking character ('*')
for each character the user types. . . . Herbert's excellent
solution is a 'display-nothing' type.
 
Back
Top