I know this is a duplicate question here on StackOverFlow but I can't find it. I may have found this code on DosTips.com as well. When I find the original links I will update the question.
Essentially this is the code you are looking for to mask password input with asterisks.
@echo off &setlocal
:username
cls
SET "username="
SET /P "username=Enter your username:"
IF NOT DEFINED username GOTO username
:password
cls
<nul set /p "=Enter your password: "
call :HInput password
IF NOT DEFINED password GOTO password
setlocal EnableDelayedExpansion
echo user:%username% pass:!password!
pause
goto :eof
:HInput [ByRef_VarName]
:: inspired by Carlos
:: improved by pieh-ejdsch
if "%__HI__%" neq "__HI__" (
setlocal DisableDelayedExpansion
set "S=" &set "N=0" &set "__HI__=__HI__"
for /f %%i in ('"prompt;$h&for %%i in (1) do rem"') do set "BS=%%i"
)
set "C="
for /f "eol=1 delims=" %%i in ('xcopy /lwq "%~f0" :\') do set "C=%%i"
set "C=%C:~-1%"
setlocal EnableDelayedExpansion
if not defined C (
echo(
if "%~1"=="" (
echo(!S!
endlocal &endlocal &exit /b %N%
) else (
if defined S (
for /f delims^=^ eol^= %%i in ("!S!") do endlocal &endlocal &set "%~1=%%i" &exit /b %N%
) else endlocal &endlocal &set "%~1=" &exit /b 0
)
)
if "!BS!"=="!C!" (
set "C="
if defined S set /a "N -= 1" &set "S=!S:~,-1!" &<nul set /p "=%BS% %BS%"
) else set /a "N += 1" &<nul set /p "=*"
if not defined S (
endlocal &set "N=%N%" &set "S=%C%"
) else for /f delims^=^ eol^= %%i in ("!S!") do endlocal &set "N=%N%" &set "S=%%i%C%"
goto HInput