Sunday, May 13, 2018

A BAT File to Create a Hidden Folder


Versions of this BAT file have been around for years. Still, I though that it was an interesting trick to hide a folder (and its contents) on your computer.

Open Notepad and copy the following script (every thing between the ------- lines) and save the file as NAME.BAT  You can name the file anything that you wish, but it must be saved as a .BAT file, not a .TXT file, for it to run.

In the script change the text "Your-Password-Here" to whatever you want you password to be.

When you run the BAT file it will create a folder (MDLOCKER) called "Locker". You can change the folder name in the script if you wish.

You use the folder like you would any other, but are able to use your BAT file to hide the folder. When your folder is visible, run your BAT file to hide it. When the folder is hidden, run the BAT file to make it visible.

------
cls
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the 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 Locker "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 folder
set/p "pass=>"
if NOT %pass%==Your-Password-Here goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End
-----------

How It Works.

This BAT file creates a folder "LOCKER" on your computer. When you run the BAT file again, it renames the folder and sets its attributes to a Hidden / System Folder with the Windows Class Identified of Control Panel.

The password in the BAT file is a simple IF/THEN statement. When the correct password is entered the BAT file runs and renames the folder making it visible. If an incorrect password is entered the BAT file fails and the folder remains hidden.

It is important to note that the LOCKER folder is not actually password protected. You can navigate to that folder from the command line and reset its attributes. If you understand file attributes you can do everything the BAT file does by typing commands into the command line. The BAT file just makes it easier. To protect documents within the hidden folder you should consider some form of encryption, such as Microsoft Office Encryption.

If you want to learn more about this BAT file, do a Google search for "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" and there will be several additional articles for you to read.

This YouTube video explains how to use the above BAT file.

Go ahead and try it out.

--
Although this BAT file uses the Windows Class Identifier (CLSID): "Control Panel", there are other CLSID that could be used, such as:

My Computer.{20D04FE0-3AEA-1069-A2D8-08002B30309D}
Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}
Printers.{2227A280-3AEA-1069-A2DE-08002B30309D}
Internet Explorer.{871C5380-42A0-1069-A2EA-08002B30309D}
Network Neighborhood.{208D2C60-3AEA-1069-A2D7-08002B30309D}
Subscriptions: {F5175861-2688-11d0-9C5E-00AA00A45957}
ActiveX Cache Folder.{88C6C381-2E85-11D0-94DE-444553540000}

Whenever the Windows shell needs to access such a system folder, it uses the CLSID to search through the Windows Registry to find the appropriate .dll or other object.

An advantage to using this technique to hide a folder is that it doesn't require any outside software. You could hide a folder on a company network, even if you are unable to install executables (as long as you can access system files).

To add a bit more security to your hidden folder, keep your BAT file on removable media (such as a CD). Copy the BAT file to your computer desktop when you need to access your hidden folder, and when you are done delete the BAT file from your desktop and take the CD with you when you leave.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.