Create Your Own Password Protected Folder

Create Your Own Password Protected Folder

July 25, 2009

Ever had a situation where you want to keep your file secretly. Avoid others from accessing your private data by your own application! Write the codes by yourself. In today how2.0 tutorial, i'll teach you a simple batch [*.bat] file programming, using only your notepad. This program runs under command prompt "CMD". Maybe it's too advance to learn this before you know about the basic of batch [*.bat] file itself. But nevermind, i'll explain the codes for your understanding. Yeah, lets rock the codes!! Here it is :

Step 1
Firstly, i'll explain about the method used in this batch [*.bat] program.

1st method :
Here, we'll use an unique method to create a folder that seen as "control panel". Magic? Yeah. This unique string : Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D} ,represent as "control panel" folder. So, if you rename any folder using this string, it will become a "control panel" but actually that is your folder. The is many more unique string such as:

  • Internet Explorer.{FBF23B42-E3F0-101B-8488-00AA003E56F8}
  • Recycle Bin.{645FF040-5081-101B-9F08-00AA002F954E}
  • My Computer.{20D04FE0-3AEA-1069-A2D8-08002B30309D}
  • My Documents.{ECF03A32-103D-11d2-854D-006008059367}
  • Fonts.{BD84B380-8CA2-1069-AB1D-08000948F534}
You can change the middle string such as, "MyOwnFolder.{21EC2020-3AEA-1069-A2DD-08002B30309D}". The folder will appear as "control panel" icon, named "MyOwnFolder", but you will also redirected to control panel folder. Thats means, your folder cannot be accessed as usual. The data inside the folder will remain safety.

2nd method :
We'll change the folder attributes to "system files attribute" and "hidden files attribute" by using "attrib" method that i've explain in my last post. [attrib x:/filename +s +h]

Step 2
Copy & Paste these codes into your notepad [start > run > "notepad"]. These codes combine the two method i've mention above to secure your folder.

cls
@ECHO OFF
title Folder Passworder [Beta Test] by zXara
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%== password 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

[explanation]
  1. @ECHO OFF <<- the programs header
  2. title Folder Passworder [Beta Test] by zXara <<- your program title
  3. if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK <<- tell CMD to go to :UNLOCK path it the folder "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" is exist
  4. if NOT EXIST Locker goto MDLOCKER <<- tell the CMD to go to :MDLOCKER path if the folder "Locker" does'nt exist
  5. :CONFIRM <<- Command path
  6. echo Are you sure u want to Lock the folder(Y/N) <<- tell CMD to print out text "Are you sure u want to Lock the folder(Y/N)" on the screen
  7. set/p "cho=>" <<- Choice selection
  8. if %cho%==Y goto LOCK <<- tell CMD to go to :LOCK path if key Y was pressed
  9. if %cho%==y goto LOCK <<- tell CMD to go to :LOCK path if key y was pressed
  10. if %cho%==n goto END <<- tell CMD to go to :LOCK path if key n was pressed
  11. if %cho%==N goto END <<- tell CMD to go to :LOCK path if key N was pressed
  12. echo Invalid choice. <<- tell CMD to print out text "Invalid choice" on the screen
  13. goto CONFIRM <<- tell CMD to go to :CONFIRM path
  14. :LOCK <<- Command path
  15. ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" <<-CMD will rename the "locker" folder to "control panel"
  16. attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" <<- CMD will add "system" & "hidden" file attribute to the folder
  17. echo Folder locked <<- tell CMD to print out text "Folder locked" on the screen
  18. goto End <<- tell the CMD to go to :UNLOCK path
  19. :UNLOCK <<-Command path
  20. echo Enter password to Unlock folder <<- tell CMD to print out text "Enter password to Unlock folder" on the screen
  21. set/p "pass=>" <<- Choice selection
  22. if NOT %pass%== password goto FAIL <<-here it is, if the password is not "password", CMD will move to :FAIL path
  23. attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" <<- CMD will remove "system" & "hidden" file attribute to the folder
  24. ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker <<-CMD will rename the "control panel" folder to "locker"
  25. echo Folder Unlocked successfully <<- tell CMD to print out text "Folder Unlocked successfully " on the screen
  26. goto End< <- tell CMD to go to :END path
  27. :FAIL <<- Command path
  28. echo Invalid password <<- tell CMD to print out text "Invalid password" on the screen
  29. goto END <<- tell the CMD to go to :ENDpath
  30. :MDLOCKER <<- Command path
  31. md Locker <<- CDM will create "locker" folder
  32. echo Locker created successfully <<- tell CMD to print out text "Locker created successfully" on the screen
  33. goto END <<- tell the CMD to go to :END path
  34. :END <<- Command path
What a long explanation is'nt it.. huh.. I also burn my finger typing these post.. Hehe.. but it's my pleasure to share my knowledge with you all. :)
Ok, By simple explanation, you must change the "password" in line 22 to your own password. You can also change the title name in the 2nd line to your own. Hope you can find this tutorial useful, and, good luck coders :)

Step 3
Now you can save your file as anyfileneme.bat . You can put any name that you want as long as you keep the extension as *.bat. Now you can put your secret data inside the "locker" folder.
note that AVG will detect these commands as a HackTool. So, Make sure u make an exception list for this file to AVG. This why I hate AVG so much ~ daa
Attrib command ( Change attributes of a file or folder)

Attrib command ( Change attributes of a file or folder)

July 20, 2009

Displays, sets, or removes attributes assigned to files or directories. If used without parameters, attrib displays attributes of all files in the current directory.


Syntax

attrib [{+|-}r] [{+|-}a] [{+|-}s] [{+|-}h] [{+|-}i] [:][][] [/s [/d] [/l]]

Parameters

Parameter Description

{+|-}r

Sets (+) or clears (-) the Read-only file attribute.

{+|-}a

Sets (+) or clears (-) the Archive file attribute.

{+|-}s

Sets (+) or clears (-) the System file attribute.

{+|-}h

Sets (+) or clears (-) the Hidden file attribute.

{+|-}i

Sets (+) or clears (-) the Not Content Indexed file attribute.

[:][][]

Specifies the location and name of the directory, file, or group of files for which you want to display or change attributes. You can use the ? and * wildcard characters in the FileName parameter to display or change the attributes for a group of files.

/s

Applies attrib and any command-line options to matching files in the current directory and all of its subdirectories.

/d

Applies attrib and any command-line options to directories.

/l

Applies attrib and any command-line options to the Symbolic Link, rather than the target of the Symbolic Link.

/?

Displays help at the command prompt.

Remarks

  • You can use wildcard characters (? and *) with the FileName parameter to display or change the attributes for a group of files.
  • If a file has the System (s) or Hidden (h) attribute set, you must clear the attribute before you can change any other attributes for that file.
  • The Archive attribute (a) marks files that have changed since the last time they were backed up. Note that the xcopycommand uses archive attributes.

Examples

To display the attributes of a file named News86 that is located in the current directory, type:

attrib news86 

To assign the Read-only attribute to the file named Report.txt, type:

attrib +r report.txt 

To remove the Read-only attribute from files in the Public directory and its subdirectories on a disk in drive B, type:

attrib -r b:\public\*.* /s 

To set the Archive attribute for all files on drive A, and then clear the Archive attribute for files with the .bak extension, type:

attrib +a a:*.* & attrib -a a:*.bak 
July 20, 2009

With (native) Windows NT 4+ commands:

    NET LOCALGROUP Administrators

Or, to remove header and footer lines:


FOR /F "delims=[]" %%A IN ('NET LOCALGROUP Administrators ˆ| FIND /N "----"') DO SET HeaderLines=%%A
FOR /F "tokens=*" %%A IN ('NET LOCALGROUP Administrators') DO SET FooterLine=%%A
NET LOCALGROUP Administrators | MORE /E +%HeaderLines% | FIND /V "%FooterLine%"

Inventory drivers on any PC

Inventory drivers on any PC

July 20, 2009

With (native) Windows XP Professional or Windows Server 2003 commands:

    DRIVERQUERY /V /FO CSV > %ComputerName%.csv

Or, for remote computers:

    DRIVERQUERY /S remote_PC /V /FO CSV > remote_PC.csv

List all workstations

List all workstations

July 20, 2009

With native Windows 2000 commands:

    NETDOM QUERY /D:MyDomain WORKSTATION

NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000 installation CDROM.

Delete a computer account

Delete a computer account

July 20, 2009

With native Windows 2000 commands:

    NETDOM /DOMAIN:MyDomain MEMBER \\computer2Bdeleted /DELETE

NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000 installation CDROM.

"I need an up-to-date list of disk space usage for all servers, on my desk in 5 minutes"

"I need an up-to-date list of disk space usage for all servers, on my desk in 5 minutes"

July 20, 2009

Sounds familiar?

With (native) Windows XP Professional or Windows Server 2003 commands:

    FOR /F %%A IN (servers.txt) DO (
WMIC /Node:%%A LogicalDisk Where DriveType="3" Get DeviceID,FileSystem,FreeSpace,Size /Format:csv | MORE /E +2 >> SRVSPACE.CSV
)

The only prerequisites are:

  1. SRVSPACE.CSV should not exist or be empty,
  2. a list of server names in a file named SERVERS.TXT, one server name on each line,
  3. and WMIC.EXE, which is native in Windows XP Professional, Windows Server 2003 and Vista.

The CSV file format is ServerName,DeviceID,FileSystem,FreeSpace,Size (one line for each harddisk partition on each server).

If you have a strict server naming convention, SERVERS.TXT itself can be generated with the NET command:

    FOR /F "delims=\  " %%A IN ('NET VIEW ^| FINDSTR /R /B /C:"\\\\SRV\-"') DO (>>SERVERS.TXT ECHO.%%A)
Notes: (1) assuming server names start with "SRV-"; modify to match your own naming convention.
(2) delims is a backslash, followed by a tab and a space.