Introduction: How to Put a Password on Any USB Flashdrive

Picture of How to Put a Password on Any USB Flashdrive

The following steps is a great way to put a password on any USB flashdrive. The following is a .bat file and fairly simple to make. [Only works on windows]


I am not responsible for any lost and corrupted files. I highly suggest you back up your files before continuing. USE WITH CAUTION

Step 1: Move Your Folders

First, plug in you drive, and go to your flash drive folder. Then create a folder. Lets name this folder "Lock." Now move all your flash drive folders into "Lock" Make sure "Lock" is still on the flash drive.

Step 2: Hide Your Folder

First open CMD (if you don't know what this is and want to learn check out my instructable on it) type in "g:" then hit enter and type "attrib Lock +s +h" (if you have a different folder name instead of "Lock" use the name of your folder) this should now make you folder "disappear" The folder is now invisible. Although still accessible, it cannot be seen unless the specfic folder path is seen.

Step 3: Actual Batch Coding

Open notepad and paste the following script:


@echo off
title Orange Shadow's Folder Lock set pass= passwordlock

color a

echo----Enter Password----

set /p ui= if %ui%==%pass% (goto open)

echo Wrong Password pause

exit :open start Yo


There are two variables here: pass, and where it says "set pass=passwordlock" change passwordlock to what you want your password to be.

Next, "open start Yo" change to the name of what your new folder's name is.

save this script as a .bat file (again, if you want to learn more about bat files you can check out my instructable) in the folder you wish to

Step 4: Voila

Now, whenever you attempt to access the folder on the drive, you'll have to go through a secure password first.

Step 5: Turning Into an .exe

The thing about having a .bat file is that you can easily edit the coding, making it accesbile to anyone. really Making this entire project more of a novelty than anything else.

However, There is a solution. Turning the .bat in a .exe (executable program).

To do this click this link here and download the program (or use any other .bat to .exe converter you wish). Follow the procedures, and you should be set.


JacobG69 (author)2016-08-28

Hi, I was viewing this and made flether-1's version a little easier to use

@echo off

title Drive Locked

color 2


echo================= & echo Enter Password & echo ================

set /p password=

if %password%==YOURPASSWORDHERE goto :1

echo Wrong Password


goto :0


echo Success!



ChrisO136 (author)JacobG692017-10-06

Oh my god thank you so much for this updated version. I used the other one and couldn't open my file and spent several hours trying to fix it myself before looking through these. The original kept givving me error mesages.

iambeginner (author)JacobG692016-09-15

i used this code. thanks bro.

BrianCho (author)2017-08-22

i typed g: in cmd but its says

The system cannot find the drive specified.

casinoslotguy (author)2017-01-13

I got the password box working.. My question is, how would i hide the letters of the password under astrix, so someone behind me or walking by when i access the password box does not see my password?

RasmusK6 made it! (author)casinoslotguy2017-04-25

before the set/p... insert 1 row with xxx color ef xxx and in correct and wrong answer insert one row in between color 0 when entering password the screen goes yellow and text is white, you will not see anything, type the password and you should be good, btw insert xxx pause xxx after xxx echo ---enter password--- xxx ps i added my batch file as image

I too had this question, but unfortunately, I don't think it is possible. Batch is a pretty simple language, and of course has it's limitations, this being one of them. Thanks for checking out my instructable!

Ma Ry (author)2017-01-05

pahelp naman po pls. sa thesis namin need po namin ng codes para malock ung external hard drive then dapat di pwede mareformat hanggat mali ung password. thank you ??

arfuxo155255 (author)2016-09-28

Folder Lock is a convenient tool to add password to any folder on Windows. The steps are simple and the protection is quite secure. You can follow the steps in here:

lizijish (author)2016-04-26

File Folder performs better than the above tool because it has a much cleaner user interface instead of command line. You can check out:

dfletcher-1 (author)2016-04-14

Fixed his code and made some adjustments if anyone is interested. Just change the bold "test" to whatever you want your password to be and change the E:\Files to the drive letter and folder name.

@echo off
title Drive Locked
color b
echo================= & echo Enter Password & echo ================

set /p password=
if %password%==test (START E:\Files)

echo Wrong Password pause

exit :Files
PsycheE (author)2016-04-04

i encounter error.. "Enter is not part of external or internal command" :'(

PsycheE (author)2016-04-04

where do i need to save the notepad i created? do i need to have the program installed?

justice786 (author)2015-08-25

i am stuck on step 2 please help

About This Instructable




Bio: Ming DeMers Senior Director of Fuel Ignition Division Jet Propulsion Laboratory 4800 Oak Grove Dr, Pasadena, CA 91109
More by Orange Shadow:Make Your Computer Faster by Installing Chromium OS5$ AC UnitThe Keyless Keyboard
Add instructable to: