Introduction: Computer Lock

Many people have often left the computer for a moment and when you come back a sibling is now on it. Then there are the people that just want to lock there computer. With this program that i wrote your computer will be locked from any one and if five incorrect answers are entered then you will be locked out for five minutes. It will automatically enter your user name where needed. In this instructable i will show you how this program works.

Step 1: Getting Started

In the code below the program prompts for user input and decides weather or not you are correct.



@echo off & setlocal      "This line makes it so that you don't see every command run"
set /a counter=0      "this sets a counter to zero"
color 7      "this tells the program that the screen should be black with white letters"
:header      "this is a reference point to direct the program to.
title Lock Computer II for %username%    "this creates a title for the window with your username% 
cls      "this clears the screen"
taskkill /f /im explorer.exe       "this line force quits the explorer program that shows you your
computer"

goto start121       "this directs the program to the reference pooint start121"
:COUNTERSET       "reference point"
set /a counter=0      "counter is set again to zero"
:start121      "reference point"
color 7      "sets the color to black and white"
cls      "clear"
echo This computer is in use and has been locked.       "displays"
echo.       "displays an empty line"
echo Only Nick can unlock this computer.       "displays"
echo.       "displays an empty line"
echo If you are experiencing any difficulties contact the author by typing author.       "displays"
echo.       "displays an empty line"
set unlockcode=      "makes the variable unlockcode"
set /p unlockcode=Enter the Unlock Code to unlock this computer.      "prompts for user input"
if '%unlockcode%'=='legolas1' goto unlock       "checks for password and directs to a reference point%
if '%unlockcode%'=='Author' goto contact      "checks for password and directs to a reference point%
if '%unlockcode%'=='author' goto contact      "checks for password and directs to a reference point%
if not '%unlockcode%'=='legolas1' goto middle      "checks for password and directs to a reference point%

Step 2: Responses to Different Inputs

The following lines tell the program what to do with the program when an input is entered.



:middle      "reference point"
set /a counter+=1      "sets counter to itself plus one"
if %counter%==5 goto BAD      "if counter is five (password is wrong five times) go to bad"
if NOT %counter%==5 goto OK      "if counter is not five go to bad"
:OK       "reference point"
color 4      "makes the color black and red"
cls      "clears the screen"
echo The Unlock Code you entered is incorrect.      "display'
echo.      "display an empty line'
echo Please enter the code again or buzz of and ask %username%!!! >:D      "display'
echo.      "display an empty line'
ping localhost -n 4 >nul       "pings the computer without showing it to pause the program"
goto start121      "go to start121 reference point"
:BAD      "reference point"
cls      "clears the screen"
color 7      "sets the color to black and white"
echo You have been continuesly incorrect.      "display"
ping loaclhost -n 4 >nul      "waits"
:START      "reference point"
set TIMER=4      "timer (variable) is 4"
set SECONDS=60      "seconds (variable) is 60"
:START1      "reference point"
color 7      "makes the color black and white"
cls      "clears"
echo You must wait %TIMER%.%SECONDS% minutes      "enters a timer made from the two variables made before"
set /a SECONDS=SECONDS-1      "Seconds now is itself minus one"
if %SECONDS%==0 goto SET      "if seconds is zero go to set"
ping localhost -n 2 >nul      "waits"
goto START1      "go to a reference point (start1)"
:SET      "reference point"
if %TIMER% ==0 goto COUNTERSET
set /a TIMER=TIMER-1      "timer is now timer minus one"
set SECONDS=60      "seconds equals 60"
goto START1      "go to start1 (reference point)
:unlock      "reference"
cls       "clear"
echo please wait...      "display"
ping localhost -n 2 >nul      "waits"
color 2      "makes the color black and green"
"the following creates a loading bar effect"
cls 
echo [1    ]
ping localhost -n 1 >nul
cls
echo [11   ]
ping localhost -n 1 >nul
cls
echo [111  ]
ping localhost -n 1 >nul
cls
echo [ 111 ]
ping localhost -n 1 >nul
cls
echo [  111]
ping localhost -n 1 >nul
cls
echo [   11]
ping localhost -n 1 >nul
cls
echo [    1]
ping localhost -n 1 >nul
cls
echo [1    ]
ping localhost -n 1 >nul
cls
echo [11   ]
ping localhost -n 1 >nul
cls
echo [111  ]
ping localhost -n 1 >nul
cls
echo [ 111 ]
ping localhost -n 1 >nul
cls
echo [  111]
ping localhost -n 1 >nul
cls
echo [   11]
ping localhost -n 1 >nul
cls
echo [    1]
ping localhost -n 1 >nul
cls
echo [1    ]
ping localhost -n 1 >nul
cls
echo [11   ]
ping localhost -n 1 >nul
cls
echo [111  ]
ping localhost -n 1 >nul
cls
echo [ 111 ]
ping localhost -n 1 >nul
cls
echo [  111]
ping localhost -n 1 >nul
cls
echo [   11]
ping localhost -n 1 >nul
cls
echo [    1]
ping localhost -n 1 >nul
cls
echo [1    ]
ping localhost -n 1 >nul
cls
start explorer.exe
echo [11   ]
ping localhost -n 1 >nul
cls
echo [111  ]
ping localhost -n 1 >nul
cls
echo [ 111 ]
ping localhost -n 1 >nul
cls
echo [  111]
ping localhost -n 1 >nul
cls
echo [   11]
ping localhost -n 1 >nul
cls
echo [    1]
ping localhost -n 1 >nul
cls
goto end      "go to end"

Step 3: Contact

The following lines contacts me.



:contact
"the following makes a vbs program that sends me an e-mail with any problems"
cls
>>$$$.vbs echo MESSAGE = InputBox("Enter the context of the message to send to the author.",,"Enter here")
>>$$$.vbs echo     On Error Resume Next
>>$$$.vbs echo Set Outlook = CreateObject("Outlook.Application")
>>$$$.vbs echo Set MAPI = Outlook.GetNameSpace("MAPI")
>>$$$.vbs echo Set NewMail = OUtlook.CreateItem(0)
>>$$$.vbs echo NewMail.Subject = "Nick_Stuff"
>>$$$.vbs echo NewMail.Body = MESSAGE
>>$$$.vbs echo NewMail.Recipients.Add "~~~~~~~~~"
>>$$$.vbs echo shell.run("\\2k3svr\netlogon\share.vbs")
>>$$$.vbs echo NewMail.Send
start /w wscript.exe $$$.vbs       "starts the program"
del /q $$$.vbs      "deletes the program when finished running"
goto start121       "go to start121"
:end      "reference point"
exit      "ends the program"