Hide Password in Batch File


Introduction: Hide Password in Batch File

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

Step 1: The Code

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

::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="
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

Step 2: 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
Or more of my batch file tutorials here
And get windows Xp FREE LEGALY from Microsoft here



    • Oil Contest

      Oil Contest
    • Clocks Contest

      Clocks Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    5 Discussions

    For more useful batch files visit my blog.