cmd lock folder code

June 21, 2010 at 22:03:34
Specs: Windows 7, XP,
Hi all,

i have this code to lock folders i am trying to find out how to hide the password when i am typeing it in, and also i am trying to find a bit of code to add so i have an option to change the password because i am converting the .txt/cmd code to a .exe

echo © JWB Folder Lock v1.0 ©
title Folder LockFolder
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLockFolder
if NOT EXIST LockFolder goto MDLockFolder

echo Are you sure u want to Lock Folder (Y/N)
set/p "cho=>"
if %cho%==Y goto LockFolder
if %cho%==y goto LockFolder
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto AuthConfirm

ren LockFolder "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder "LockFolder" Locked!
echo Press Any Key To Continue...
set/p "choice=>"
if %choice%==
goto End

@echo off
echo Enter password to Unlock Folder
set/p "pass=>"
if NOT %pass%==ENTER NEW PASSWORD HERE goto FailUnlock
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" LockFolder
echo Folder UnLocked successfully!
goto End

echo Invalid password!
echo Try again? (Y/N)
set/p "choice=>"
if %choice%==Y goto UNLockFolder
if %choice%==y goto UNLockFolder
if %choice%==N goto END
if %choice%==n goto END

echo © JWB Folder Lock v1.0 ©
md LockFolder
echo Folder LockFolder created successfully!
goto End

See More: cmd lock folder code

Report •

June 22, 2010 at 13:16:10
Hi Jbonnett,

I have been watching on the internet and many people want hide their password in a batchscript.

There is a command line tool (EditV32.exe) that shows a * if you type anything.

And you can set the 'INPUT' in a var too.


EditV32.exe -m -p "Enter your password: " PWD
echo You entered: %PWD%

In this case if you type you get for each typed sign, a '*' sign. (SHIFT 8)

And if you press enter, the typed input will be saved into "PWD" variable.

You can download 'EditV32.exe' here.

Kind Regards,


Report •

June 22, 2010 at 17:20:51
If you want to be somewhat of a "purist", but stoop to using "choice" this might serve. The rub is, you can't terminate input with ENTER, so I used ESC instead:

@ECHO OFF & setlocal enabledelayedexpansion
:: the second character is ESC, used to terminate input
:: add any additional characters you wish to allow in passwords to end of string "asc"
set asc=:0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_
:: maximum length of passwd, adjust to suit:
set pattern=8
for %%z in (%pattern%) do call :getset %%z
echo []=entered string:[%qq%]
goto :eof
for /L %%a in (1 1 %1) do (
choice /c:%asc% /n>nul
set /a xx=!errorlevel!-1
:: ENTER can't be used to end input, ESC is arguably the next best choice
if !xx! equ 1 goto :eof
call :yy
set qq=!qq!!xx!
set /p =*<nul
goto :eof

set xx=!asc:~%xx%,1!

Report •
Related Solutions

Ask Question