Introduction: Screen Lock (VB.NET)

I'm going to show you how i made my own screen lock .. so maybe you can make your own.
or you could just use mine ;)

You see all around the internet: 'Screen Lock !' .. and you download and install and it locks you pc screen so no-one can access your pc while your not there.
( Windows lock does the same thing unless you don't have a password. )

This program that i made uses VB.NET to lock the screen.
in the next few steps I'll show you how.

You can download my Screen Lock below.

Step 1: Making the Screen (part1)

Here I'm going to show you the first part of the screen lock ..
the first pic is the window that comes up when you run my screen lock.

on this you can set the password .. i made it so you have to set it every time so you could never forget it. Also so my program is only 1 file.

you also have the option to see it to see through .. this is just so the lock screen is slightly see through. So you can see your desktop pic faded out.

now here is how i did it:
for the password:



Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = Form1.TextBox1.Text Then

Dim process As System.Diagnostics.Process = Nothing
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = "taskkill.exe"
psi.Arguments = "/F /IM taskmgr.exe"
process = System.Diagnostics.Process.Start(psi)

Shell("explorer.exe")

Form1.Close()
End If
End Sub

what this does is checks to see if the text in textbox1 is equal to the text that you set on the first window. Then if it does it task kills task manager if it was running, And restarts explorer.exe.

here is the see through bit:


Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim process As System.Diagnostics.Process = Nothing
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = "taskkill.exe"
psi.Arguments = "/F /IM explorer.exe"
process = System.Diagnostics.Process.Start(psi)

If Form1.CheckBox1.Checked = True Then
Me.Opacity = 0.5
Else
Button1.Show()
End If
End Sub

This piece of script will task kill explorer.exe so even if someone gets past my screen lock they will not be able to do anything!
then it checks to see if the 'see through' box has been checked. If it has it sets opacity to 0.5.
If not then it shows the change background button.

Step 2: Making the Screen (part2)

Here i will show you how i made it cancel out task manager and how it says on top of other windows.

to set it as the top form you just set:
me.topmost = true
on load

to make it make task manager useless i used this coding:


Private Sub Form2_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
Dim k As Long
k = Shell("c:\windows\system32\taskmgr.exe", vbHide)
End Sub

Witch in other word says:
when lost focus, hide task manager.
but also because it is the topmost form it loos like task manager was never run.
Than when you put the right password in ... it task kills task manager.

i also used:

Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean

Select Case (keyData)
Case Keys.Control
Return True
Case Keys.Alt Or Keys.F4
Return True
End Select
Return MyBase.ProcessDialogKey(keyData)
End Function

witch makes the alt F4 useless! .. and it tries to do the same with the control key , but that didn't work .. but i left it on just in case on other systems it would.

Step 3: Screen Lock

I hope you found this instructable helpful for all of your VB.NET projects.

if you don't understand a part of this or you need help with one of your projects please leave a comment or pm me.

and please give me feed back on any problems and please rate =]

The screen lock.exe is blow if you want to download .. just make sure it is saved as a .exe
to save right click and click .. save target as or your equivalent then save as exe.

Comments

author
Sublivious made it! (author)2009-10-12

Great work! Is it possible to code it so it would not allow the use of the Log off or Shut Down buttons when ctrl+alt+del is hit?

author
xp4xbox made it! (author)xp4xbox2015-12-21

Yeah, I disabled nearly every ctr-alt-delete option using registry tweaks in my screen lock but I don't think you could without registry tweaks.

author
iRule made it! (author)iRule2009-10-16

It might be but i tried to make it like that, by doing things like disabling ctrl or alt
but windows has made it so ctrl+alt+del is always possible .. so if a program freezes you can end it.

author
xp4xbox made it! (author)2015-12-21

It is not that secure, if you don't have a password ctr-alt-delete options could change your password, or get access to your account, that is why I made one that physically disables those options through the registry. But anyway this program inspired me to make my own just like yours except in vbscript

https://www.instructables.com/id/Vbs-Screen-Lock/

author
lanky.ninja made it! (author)2010-12-20

Would it be possible to make something similar in VBS?

author
xp4xbox made it! (author)xp4xbox2015-12-13

Of Course! I made a powerful one, almost exactly to the one made in VB.NET except mine disables task manager, removes log off and removes change password from the registry.

author
iRule made it! (author)iRule2011-03-27

sorry for a late reply, but not that i know of, as VB.NET lets you create forms and easily put in buttons etc, whereas VBS tends to be more background processes without as much visual.
Although my knowledge of plain VBS is limited compared to .NET.

author
Mer Boy AnthonyD made it! (author)2014-11-26

Hi. Good day! Thanks for the code, I actually copied a portion of it for my project. Already disabled the task manager, taskbar, and alt-tab. But do you have any idea how to make it in such a way that it would really look like all the keys are locked? Because when I press the windows key/Atl tab, something still pops up on the screen. Thank you :D

author
limbo made it! (author)2014-06-13

Thank you for sharing this.
I'm creating a system lock utility called Raptor with advanced features and your approach gave me some more ideas to add on it.

Raptor v.0.0.0.13 - beta.jpg
author
jalal0072010 made it! (author)2011-06-01

thanks for your information..............

author
Arbitror made it! (author)2009-10-05

Great job! Would you mind giving the whole code instead of code blocks? Thanks!

author
Arbitror made it! (author)Arbitror2009-10-05

Five stars by the way!

author
lanky.ninja made it! (author)lanky.ninja2010-08-25

I agree five stars all the way. But would be nice to see the straight script

author
bunthoeun made it! (author)2010-02-09

Hi there,

I got an error as below

ObjectDisposedException was unhadled
Cannot access a disposed object

please help.....

thoeun

author
bunthoeun made it! (author)bunthoeun2010-02-10

Thanks for your reply, But I already fix the problem. It's because I did only one form. However I got your concept and i am trying to update this to control clients by network.

I appreciate if you got any idea to do that

Bunthoeun

author
iRule made it! (author)iRule2010-02-09

Can you explain where the error comes up, or is it as you try to run the .exe ?

author
cepacs made it! (author)2009-12-14

That is really cool.. would it be difficult to make it so that both screens blank out?  I am using dual monitors..

author
iRule made it! (author)iRule2009-12-15

im not sure =/  .... because i use 2 monitors too. but when i did it i found the only real way to do that wold be to run it twice and have a separate pass for each screen ..... but im sure somewhere on the internet is an answer to this.

author
mattronix made it! (author)2009-11-20

i like i rules instructibles i is big fan i subsribed

author
Psychic Master made it! (author)2009-10-04

very nice thank you for making this ible!!!

About This Instructable

24,542views

9favorites

License:

More by iRule:Screen Lock (VB.NET)VBS Tutorial - BasicsBatch Maker
Add instructable to: