Please tell me by which DOS command, we can protect a file or folder with a password.

pls use pkzip to compress and protect from password in dos

there is no such command in MSDOS

RE: to protect to Folder go to DOS Prompt then select the directory where the folder is like my folder is in D partition and named local
D:\attrib local +h +s

you will se your folder is hidden but it will be not show in show hidden files option..

no if you want to see your folder do the same process but put -h -s like

D:\attrib local -h -s

Remember me in your prayers

Thanks & Regards
Kashif Mohammad (+92-314-9669697)

@echo off
title password protection
If EXIST (name of your folder) goto start
goto error

echo Enter Password
set/p "pass=>"
if %pass% == (password) goto unlock
if %pass% == lock goto lock

ATTRIB -H -S (name of folder)
goto end

ATTRIB +H -S (name of folder)
goto end

echo Invalid


This line is not to be written in the batch file. This has been written to inform
You that in places where the words have been written in bracket there should
Be replaced by the aims written in the bracket and I would prefer you to put the
File you want to secure and the batch file in one folder which consists of only
Two folders. Thank you.

please don't revive old threads, and certainly not by posting such utter nonsense.

Start CMD prompt
Code for protecting the Folder or files
write cacls "Files or Folder name" /p everyone:n
Code for Unprotecting the Folders or Files
write cacls "files or folders name" /p everyone:f

if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST MyFolder goto MDMyFolder
echo Are you sure to lock this 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.
ren MyFolder "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
echo Enter password to Unlock Your Secure Folder
set/p "pass=>"
if NOT %pass%== anykeylogger goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" MyFolder
echo Folder Unlocked successfully
goto End
echo Invalid password
goto end
md MyFolder
echo MyFolder created successfully
goto End

Save the notepad file as lock.bat
double click on lock.bat and a new folder will be created with name MyFolder
Copy all your data you want to protect in that New folder
Now double click on lock.bat and when command promp appears Type Y and press enter.
Now MyFolder will be hidden from you view, to access that folde double click on lock.bat
It will ask for password enter your password and done. (Default password is anykeylogger)
(To change the password replace anykeylogger with new password in the above code)

Matthew, can you show me how to password protect a drive or a few different files using a batch file? I found other applications, but they are just too much for what I want to do and that is to protect some personal files for school.


He hasn't been on Daniweb for four years. Please do not revive old threads. Start a new thread with your question.