Password Protected File Using Batch Files


Introduction: Password Protected File Using Batch Files

Today, I will be showing you how to make a password protected file that is created and accessed using a Batch (.bat) file. The method I will be using is very simple, but unfortunately it is not fool proof. Anyone with a little knowledge or experience in computer systems and Batch files will most likely be able to circumvent it rather quickly. However, it should work just fine for hiding things from people with little or no computer or batch file knowledge. 

The first time you open the file it will flash and another file will appear named "Hidden". To hide this file, simply click the original file again and it will ask you if you want to hide the file.  If you type Y then it hides it, but if you type N nothing happens. After you hide it, and later want access, you click the original file again and it will prompt you for a password.  If you get it correct, then it prompts you for another one before allowing you into your hidden file. However, if you get it wrong the letters turn green and fall like in the Matrix, then says " You have tried to access a file that is not yours. Good-Bye." and gives you a countdown. If the countdown reaches zero the computer will shutdown. You can abort the countdown by typing in a third password. The passwords are set by default to 1234, but as we will discuss later, can be changed.

Step 1: Open Notepad

We will be using notepad to type our program. So, the first step is going to be to open notepad.

Step 2: Copy & Pase

Since this is an instructable on making this specific program and not just batch files in general, you simply need to copy the code below, and then paste it into notepad. I give credit to "Tanmay Das" for a shortened and more efficient version of the coding for the random "matrix" fall.

Here is the Code:

title Cyber Attack Weapon System
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Hidden goto MDHidden
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 Hidden "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%== 1234 goto FAIL
goto UNLOCK2
echo Enter password to Unlock Your Secure Folder
set/p "pass=>"
if NOT %pass%== 1234 goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Hidden
echo Folder Unlocked successfully
goto End
@echo off
color 02
echo Warning-Virus Initiated total hardrive corruption imminent
timeout /t 5 /nobreak >nul

set count= 0
if %count% == 200 goto shutdown
echo %random%%random%%random%%random%%random%%random%%random%%random%
set /a count=%count%+1
goto tricks

shutdown -s -t 45 /c "You have tried to acces a file that is not yours. Good-Bye."
echo Enter password Start Abort Sequence
set/p "pass=>"
if NOT %pass%== 1234 goto shutdown
echo Abort Inittiated
goto Abort
C:\Windows\System32\shutdown.exe -a
Abort Successful
timeout /t 3 /nobreak >nul
goto unlock

goto end
md Hidden
echo Hidden created successfully

Step 3: Customization

The file is named "hidden " by default. If you want to change the name, you have to look in the code and anywhere it says "hidden" replace with your name of choice. You have to replace it a total of 7 times.

The passwords are set by default to 1234. They can also be changed. To change the passwords find in the code where it says: 

if NOT %pass%== 1234 goto

And replace 1234 with your password of choice. There are 3 different passwords spread throughout the program. I recommend having a different password for each.

If you want to change the amount of "matrix" letter fall find the part of the code that looks like this:

set count= 0
if %count% == 200 goto shutdown
echo %random%%random%%random%%random%%random%%random%%random%%random%
set /a count=%count%+1
goto tricks

Then replace 200 with your number of choice. Increasing the number will increase the length of the "matrix" fall, while decreasing the number will shorten it.

None of the program is permanent.  If you wish to change it after you save it, right click on its icon and click edit. You can now edit the file as you wish, but before you edit it I recommend making a copy of it just in case you mess something up. I personally always make copies of anything I'm programming.

Step 4: The Most Important Part

Once you are satisfied with your program, you must save it as a .bat file. If you do not save it correctly then it will not work.

First, click save as:

Second, name the file whatever you want, but after the name type .bat 
For example, "example.bat"

Last, Click Save

Step 5: Conclusion

Please feel free to modify the file as you wish, and have fun with it!  If you could please post improvements in the comment section below, I would really appreciate it.

Thanks for reading



    • Clocks Contest

      Clocks Contest
    • Oil Contest

      Oil Contest
    • Water Contest

      Water Contest

    8 Discussions


    if %cho%==Y goto LOCK
    if %cho%==y goto LOCK
    if %cho%==n goto END
    if %cho%==N goto END

    Is inefficient use

    if /I %cho%==y

    And the file will not be case sensitive to the input y without the second line.


    I found a way to keep it more hidden....

    Create a new vbs and type this:


    If X="YOUR PASSWORD" Then.




    End if

    Now in you batch file put this

    call "filename".vbs

    if %ErrorLevel% == 7 "command for right answer"

    if %ErrorLevel% == 8 "Command for incorrect answer"

    I hope this will make it more hidden

    Im sorry, what happens if they keep trying and getting the passowrd wrong?


    You are correct it only hides the file, and it's really only meant to be played around with. If you need to protect something important a commercial third-party encryption program is probably the way to go.

    Your code has a lot of unnecessary code (the "echo %random%").
    You can shorten that by using a conditional loop.

    Try this
    set count= 0
    if %count% == 100 goto shutdown
    echo %random%%random%%random%%random%%random%%random%%random%%random%
    set /a count=%count%+1
    goto tricks

    Just a suggestion


    1 reply

    Thanks again, I tried it, and it works great. I'll edit the instructable to include the shortened version.

    Thanks, I've been wondering how I could shorten that part. I'll have to try it when I get some time.