Share via

How can I lock a folder so only I can access it?

Felicia Partin 0 Reputation points
2026-04-04T03:04:12.8033333+00:00

I have a folder that I would like to keep private and secure it with a passcode.

Windows for home | Windows 11 | Security and privacy
0 comments No comments

4 answers

Sort by: Most helpful
  1. Lucus-V 6,330 Reputation points Microsoft External Staff Moderator
    2026-04-15T19:39:32.1666667+00:00

    Hi Felicia Partin,

    If your data is very important and requires highest secure possible, you may consider moving it to a separate partition and use BitLocker.

    You can find more information about BitLocker in following article: BitLocker overview.

    Because BitLocker works in partition level, you need to move your data in a separate partition then encrypt it with BitLocker. Then no one can access your data without the right password or recovery code.

    Important: please have a backup of recovery code for emergency situation. Because if you lost both password and recovery code, then no one even Microsoft can help you unlock the BitLocker partition.

    I hope that above information is helpful to you.


  2. Quinn.HP 8,665 Reputation points Independent Advisor
    2026-04-04T04:34:05.67+00:00

    Just to add, for the WinRAR approach, here’s how to do it. This method is much more secure since the files are encrypted:

    1. Right-click the folder > hover over WinRAR > select Add to archive…
    2. In the window, choose RAR as the archive format > click Set password…
    3. Enter the password you want to use.
    4. Check the box “Encrypt file names” to hide the file names as well.
    5. Click OK, then OK again.
    6. Delete the original folder.
    7. Now, when you try to access the .rar archive, it will ask for the password every time.
    0 comments No comments

  3. Quinn.HP 8,665 Reputation points Independent Advisor
    2026-04-04T04:17:04.4366667+00:00

    Hello, I'm Quinn and here to help!

    To do it, open Notepad and Paste this:

    @echo off
    title Folder Locker
    if EXIST "LockedFolder" goto UNLOCK
    if NOT EXIST "CHANGETHISFOLDERNAME" goto MDLOCKER
    :CONFIRM
    echo Are you sure you want to lock this folder? (Y/N)
    set /p "cho=>"
    if /I "%cho%"=="Y" goto LOCK
    if /I "%cho%"=="N" exit
    goto CONFIRM
    :LOCK
    ren CHANGETHISFOLDERNAME "LockedFolder"
    attrib +h +s "LockedFolder"
    echo Folder locked
    goto End
    :UNLOCK
    echo Enter password to unlock folder
    set /p "pass=>"
    if NOT "%pass%"=="YOUR_PASSWORD" goto FAIL
    attrib -h -s "LockedFolder"
    ren "LockedFolder" CHANGETHISFOLDERNAME
    echo Folder unlocked
    goto End
    :FAIL
    echo Invalid password
    goto End
    :MDLOCKER
    md CHANGETHISFOLDERNAME
    echo Folder 'CHANGETHISFOLDERNAME' created. Put your files inside it.
    goto End
    :End
    
    • Replace YOUR_PASSWORD with your any password you like.
    • CHANGETHISFOLDERNAME is the name of the folder you’ll put files in. To change it, replace it with your preferred folder name.
    1. Once you’re ready with the password and folder name, in Notepad, go to File > Save As
    2. For the file name, enter anything you want as long as it ends with .bat (e.g., sample.bat)
    3. For Save as type, select All Files, then click Save
    4. Double-click the .bat file you created to run it.
    5. Enter your password to access the folder.
    6. To lock the folder again, open the .bat file and type Y when prompted.

    This method is preferable for everyday use but lacks security, as the file can be edited and viewed in Notepad. You can also download and use WinRAR for a more secure approach by locking your files with a password. It can be used for free.

    Feel free to let me know if you need further assistance, I'd be glad to help you further.

    0 comments No comments

  4. Q&A Assist
    2026-04-04T03:04:24.3133333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    On Windows 11 (non-Home editions), a folder can be locked to a specific user by encrypting it so only that account can open it.

    To encrypt the folder:

    1. Right-click the folder and select Properties.
    2. On the General tab, select Advanced....
    3. Check Encrypt contents to secure data.
    4. Select OK, then Apply, then OK again.

    This uses Windows’ built-in file encryption so only the signed-in account that encrypted the folder (or someone with its decryption key/certificate) can access the contents. Note that file encryption is not available in the Home edition of Windows.

    If the goal is cloud storage with an extra lock, OneDrive Personal Vault can be used instead of a local folder. Personal Vault is a protected area in OneDrive that requires a second step of identity verification (such as fingerprint, face, PIN, or a code sent via email/SMS) to access its contents. Files in Personal Vault on a Windows 10 PC are synced to a BitLocker-encrypted area of the local drive and automatically re-lock after inactivity.


    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.