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

Recommended Answers

All 10 Replies

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:\
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:\
D:\attrib local -h -s
(REMEMBER IT IS NOT A HIDDEN OPTION)

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

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

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

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

:error
echo Invalid

:end

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

cls
@ECHO OFF
title kakasoft.com
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST MyFolder goto MDMyFolder
:CONFIRM
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.
goto CONFIRM
:LOCK
ren MyFolder "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 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
:FAIL
echo Invalid password
goto end
:MDMyFolder
md MyFolder
echo MyFolder created successfully
goto End
: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.

Thanks!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.