I have scripted TypeHidden.bat to hide a user's response to a sensitive prompt, like a password.

The syntax for using TypeHidden.bat is:

TypeHidden "Your Message" Response


<b>"Your Message"</b> is the message you want typed to the user.
<b>Response</b>       is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain the hidden response.
Because the user cannot see their response, they are asked to Please re-type to confirm your entry.

NOTE: This works on Windows XP and later.

TypeHidden.bat contains:

@echo off
if \{%2\}==\{\} @echo Syntax: TypeHidden "Your Message" Respnse&goto :EOF
set msg=%1
set vb="%temp%\pw_%RANDOM%.vbs"
set msg=¥%msg%¥
set msg=%msg:¥"=%
set msg=%msg:"¥=%
set msg=%msg:¥=%
echo WScript.Echo CreateObject("ScriptPW.Password").GetPassword>%vb%
@echo %msg%
for /f "tokens=*" %%a in ('cscript.exe //Nologo %vb%') do (
 set response=%%a
set response=%response:"=¥%
@echo Please re-type to confirm your entry.
for /f "tokens=*" %%a in ('cscript.exe //Nologo %vb%') do (
 set confirm=%%a
set confirm=%confirm:"=¥%
if "%response%" NEQ "%confirm%" goto nq
set response=%response:¥="%
del /q %vb%
endlocal&set %2=%response%