Mask user input (password) as stars / blank

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
daffeyy
Posts: 1
Joined: 12 Feb 2020 00:31

Mask user input (password) as stars / blank

#1 Post by daffeyy » 12 Feb 2020 00:44

Hi,
I'm trying to mask user input but since I'm a newbie to CMD / batch script and trying to get my things private, I might need a little help from you all.
Here is the script (it's from Google anyway). The password is "PASSWORD".
@ECHO OFF
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDPrivate
:CONFIRM
echo lock folder? (Y/N)
set/p "cho=> "
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Private "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo folder locked
goto End
:UNLOCK
echo enter password:
set/p "pass=> "
if NOT %pass%== PASSWORD goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Private
echo Folder Unlocked successfully
goto End
:FAIL
echo invalid password
goto end
:MDPrivate
md Private
echo Private created successfully
goto End
:End
Your replies will always be useful. Thank you before. :D

ShadowThief
Expert
Posts: 920
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Mask user input (password) as stars / blank

#2 Post by ShadowThief » 12 Feb 2020 03:18

There are a couple of ways to do it

viewtopic.php?t=4664
viewtopic.php?t=8442


Post Reply