0

To all experts. I have written the following batch:

cls
@ECHO OFF
title Folder Confidential
if EXIST "Control Panel.{22EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Confidential goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the 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.
pause
goto CONFIRM
:LOCK
ren Confidential "Control Panel.{22EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{22EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
pause
goto End
:UNLOCK
echo Enter the Password to unlock folder
set/p "pass=>"
if NOT %pass%== hi goto FAIL
attrib -h -s "Control Panel.{22EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{22EC2020-3AEA-1069-A2DD-08002B30309D}" Confidential
echo Folder Unlocked successfully
pause
goto End
:FAIL
echo Invalid password
pause
goto end
:MDLOCKER
md confidential
echo Confidential created successfully
pause
goto End
:End

Please provide a way for the password to be invisible or preferably written in *.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Bob
  • 9
  • 1
  • 2
  • possible duplicate of [Can I mask an input text in a bat file](http://stackoverflow.com/questions/664957/can-i-mask-an-input-text-in-a-bat-file) – Joey Mar 23 '11 at 10:47
  • 3
    Putting the password into the file in plain sight is only slightly better than echoing it when typing. Also the latter only bites you if there is someone looking over your shoulder. But why should I care if all I need is to take a look at the batch file you so conveniently posted on the web? – Joey Mar 23 '11 at 10:49
  • possible duplicate of [What would be the Windows batch equivalent for HTML's input type="password"?](http://stackoverflow.com/q/286871/113116) – Helen Mar 23 '11 at 18:04

1 Answers1

0
echo Enter the Password to unlock folder
color 0 1 
set/p "pass=>"
cls
color 
if NOT %pass%== hi goto FAIL

looks terrible but makes it pretty hard to see what typed in.

Andy Morris
  • 3,393
  • 1
  • 21
  • 20