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

: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

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
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/

Comments

author
OzonerPlays made it!(author)2017-03-29

Please visit my instructables too

https://www.instructables.com/id/Teaching-Java-and-JavaScript

https://www.instructables.com/id/Password-Generator-With-Batch

author
Pratik+Sonigra made it!(author)2016-03-17
author
Pratik+Sonigra made it!(author)2016-03-17

For more useful batch files visit my blog.

batch798.blogspot.in

author
Batchcc made it!(author)2015-12-04
author
Batchcc made it!(author)2015-11-13

Please also look at my other instructables here

https://www.instructables.com/member/Batchcc?show=I...
Or more of my batch file tutorials here
https://www.instructables.com/id/Full-screen-batch-...

And get windows Xp FREE LEGALY from Microsoft here
https://www.instructables.com/id/Download-Windows-X...

:)

About This Instructable

4,533views

14favorites

License:

More by Batchcc:Extract Pictures From Word DocumentsSave your flash game progressBatch safely store passwords
Add instructable to: