How To Make A Folder Locker In VB.NET

Creating a program that can lock your folders and unlock them again

1. Open Visual Studio or Visual Basic.
2. Create a new windows form project and name it whatever you want.

Now to add the controls.
1. Add 3 buttons set the text on them to "Lock" and the second button "Unlock". And on the last button you write "Browse".
2. Add 2 textboxes and clear them for text.
3. Add 2 labels, write in Label1 "Folder Destination" and put it above Textbox1, Write in Label2 "Folder Name".
4. Add a folderbrowser dialog
6. Add this code to the button that says "Lock".
Dim text1 as string = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}"
Shell("cmd /c" & "ren " & TextBox1.Text & " " & TextBox2.Text & Text1) 
Shell("cmd /c" & "attrib +s +h " & TextBox1.Text & ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\*.*" & " /S /D") 
Shell("cmd /c" & "attrib +s +h " & TextBox1.Text & ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}" & " /S /D")
What this does is, it open shell and execute a command in command prompt that will first change the name of the folder and then hide it, it lock the folder and hide it completly, you will NOT be able to find the folder by going to folder options and select show hidden folders, so remember where the folder you lock is.
7. Add this code to the button that says "Unlock".
Dim text1 as string = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}"
Shell("cmd /c" & "attrib -s -h " & TextBox1.Text & ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}" & " /S /D") 
Shell("cmd /c" & "attrib -s -h " & TextBox1.Text & ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\*.*" & " /S /D") 
System.Threading.Thread.Sleep(1000) 
Shell("cmd /c" & "ren " & TextBox1.Text & Text1 & " " & TextBox2.Text)
What this does is it does the reversed of what the "Lock" button did it will unlock the folder.
8. Now the code for the button that says "Browse" add this code
FolderBrowserDialog1.ShowDialog() TextBox1.Text = FolderBrowserDialog1.SelectedPath last = Path.GetFileName(FolderBrowserDialog1.SelectedPath) TextBox2.Text = last TextBox1.Text = TextBox1.Text.Replace(".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}", "") 
TextBox2.Text = TextBox2.Text.Replace(".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}", "")
What this does it it open the folderbrowser dialog and put the full path of the folder you selected into textbox1.text and put the name of the selected folder in textbox2.text. When your done it should look kinda like mine, i have some added feautures which i will make a tutorial on later.
Folder Locker , VB.NET
Please dont repost without giving credits to the right website, thank you
Written and coded by: AnoPem




29 comments

nice tutorial , well explained

Reply

Hey Dude:
How can i download your Added feature Folder locker:
It has well look. More Function... and many more
Please Send it to me.
With the Project File:

And Can you Explain this: What is this?:
2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\*.*" & " /S /D")

how this Folder Locker really lock or rename or something????

Reply

2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\*.*" & " /S /D")
This is the part of the code that hides every file in the selected folder

And about the new version write to me on skype and we figure something out, my skype name is per-pem

Reply

Does this works If i do this
GOTO : Tool -> Folder Option -> View

Then Clear,

Hide extension of known file type.

Hide protected operating system files.

Press Apply

Then Every Hidden System File Can be Seen.

Reply

Ok Dude,
Please send me request on skype...
My skype name is: dm-product
and symbol is same as I have used as logo.
We will just talk about the new version.

Please send it soon,
So that we can talk about the newer version.

Reply

It should still hide it from that

Reply

i have a problem in this code bro plz help me to resolve it

FolderBrowserDialog1.ShowDialog() TextBox1.Text = FolderBrowserDialog1.SelectedPath last = Path.GetFileName(FolderBrowserDialog1.SelectedPath) TextBox2.Text = last TextBox1.Text = TextBox1.Text.Replace(".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}", "")
TextBox2.Text = TextBox2.Text.Replace(".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}", "")

Reply

What is the problem you get ?

Reply

http://i41.tinypic.com/121fl8h.png here is the problem

Reply

Dim last As String

FolderBrowserDialog1.ShowDialog() TextBox1.Text = FolderBrowserDialog1.SelectedPath last = Path.GetFileName(FolderBrowserDialog1.SelectedPath) TextBox2.Text = last TextBox1.Text = TextBox1.Text.Replace(".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}", "")
TextBox2.Text = TextBox2.Text.Replace(".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}", "")

Reply

Hi, AnoPem.

I translate it to C#, works beautiful.

Unfortunately the lockMode is easily bypassed with winRAR (Just compress folder and extract the files), and the hided file folder can be found with "dir /as"

But to me the important is the code, really thanks for share.

Reply

The problem is there need a space, add a space before "last = getfilename...."
Good luck

AnoPem.

Reply

Yes i know about the winrar bypass and im looking for a way to fix this, so if you have any sugguestions feel free to post them

AnoPem.

Reply

The problem is there need a space, add a space before "last = getfilename...." and before "textboxx1.text = "
Good luck

Reply

I have the same problem as Khawaja Ali.

I can't get it fixed by adding a space. Can you please re-post a fixed code for that part only? (Browse button)

Reply

I figured it out on my own. I changed the code a bit. :D

Reply

Heres how the code should look like for the lock button,

http://pastebin.com/5ira80eZ

Reply

Lock button code fix, should look like this,

http://pastebin.com/5ira80eZ

Reply

dude,
How to add history option in this...
As I show the image I saw listbox/listview in it,
Can you give me the code for this.
And also explain how to add column and row in it

Reply

We decided to upload the source code for a newer version of this, this can be downloaded here. http://anopemp.com/folderlock.php

But please be aware there may be alot of bugs in this version

Reply

The code of "Browse" Button should be like that:

http://pastebin.com/Kw6n49K0

Reply

here is fixed errors in the browse button :
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim last As String
FolderBrowserDialog1.ShowDialog()
TextBox1.Text = FolderBrowserDialog1.SelectedPath
last = Path.GetFileName(FolderBrowserDialog1.SelectedPath)
TextBox2.Text = last
TextBox1.Text = TextBox1.Text.Replace(".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}", "")
TextBox2.Text = TextBox2.Text.Replace(".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}", "")
End Sub
you just made some false spaces and you forgot to declare "last" as string :) , thnx for the share and good job !

Reply

and i forgot something , for the line:
last = Path.GetFileName(FolderBrowserDialog1.SelectedPath)
you have to import this in the beginning of the code :)
Imports System.IO

Reply

how they add their name on the right click?
I mean whenever I click on Folder (right Click) then I get text that Lock folder with ...
How to do this?

Thank you

Reply

what is folderbrowserdialog it is making an error
i cant make it yar help me

Reply

It can be easily bypassed by WinRAR.

Reply

FolderBrowserDialog is a dialog which lets you to view the folders on your computer or any data storage device attached. What kind of error do you get? I mean what is the error?

Reply

Dude Please ... Am Getting A Lot Of Errors ...
I browse through a lot of websites in search of stuffs
so coming back here to read reply will be a problem
Please send me your project
kwabynalilwayne@gmail.com

Reply

Please put the code of Unlock Button in pastebin

Reply

Post a Comment