Hide Password in Batch File

by Batchcc in Circuits > Microsoft

31932 Views, 15 Favorites, 0 Comments

Hide Password in Batch File

FN1G24DHINMX373.MEDIUM.jpg
Do you need to type secret information in to a batch file but only see stars here is the file to do it!

The Code

cmd1.png
Here is the code copy between the xxxxxxxxxxxx's
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx
@Echo Off
SetLocal EnableExtensions EnableDelayedExpansion

Set /P "=Enter a Password:" < Nul
Call :PasswordInput
Echo(Your input was:!Line!

Goto :Eof

:PasswordInput
::Author: Carlos Montiers Aguilera
::Last updated: 20150401. Created: 20150401.
::Set in variable Line a input password
For /F skip^=1^ delims^=^ eol^= %%# in (
'"Echo(|Replace.exe "%~f0" . /U /W"') Do Set "CR=%%#"
For /F %%# In (
'"Prompt $H &For %%_ In (_) Do Rem"') Do Set "BS=%%#"
Set "Line="
:_PasswordInput_Kbd
Set "CHR=" & For /F skip^=1^ delims^=^ eol^= %%# in (
'Replace.exe "%~f0" . /U /W') Do Set "CHR=%%#"
If !CHR!==!CR! Echo(&Goto :Eof
If !CHR!==!BS! (If Defined Line (Set /P "=!BS! !BS!" Set "Line=!Line:~0,-1!"
)
) Else (Set /P "=*" If !CHR!==! (Set "Line=!Line!^!"
) Else Set "Line=!Line!!CHR!"
)
Goto :_PasswordInput_Kbd
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The Code Explained

The code will allow you to enter a password then this password will be displayed on the screen to change this remove echo !line!

Please view the rest of my work here
https://www.instructables.com/member/Batchcc?show=INSTRUCTABLES
Or more of my batch file tutorials here
https://www.instructables.com/id/Full-screen-batch-matrix/
And get windows Xp FREE LEGALY from Microsoft here
https://www.instructables.com/id/Download-Windows-Xp-legally-FREE-from-microsoft/