There have been many programs on these forums that lock the computer when a certain drive is removed. This is a very simple yet powerful contribution. Just put the script on a thumb drive, run it, and when the drive is removed the monitor will turn off and input will be disabled. This will allow you to use the drive like a key. Plug it back in and everything is back to normal. It does not write to the registry, create any files, or use any includes. Here is the code:
this is very cool, but what if someone, lets say mr. a has the drive taken away, so the computer is locked and mr. a is somewhere else and mr. b wants to go on the computer, maybe it is an idee to ask mr. b for a password?
EDIT
and i have changed a bit, it will ask you now for a password if you want to close the app
Thanks for the replies guys! As for the modification that was posted, I made the script specifically to only unlock the computer when the drive was in. No input except for ctrl-alt-del is able to get in so in the second loop you could use _IsPressed (in Misc.au3) to check if ctrl-alt-del is pressed then pop up a password box or something. But the user would still have to input information which defeats the whole purpose of having continous BlockInput(1)'s. You could have the password box fullscreen, ontop, and always closing task manager as a quick solution. I think that would work.
The program has been updated. I have added a shorter sleep in the lock loop and have effectively disabled the task manager by running it with a @SW_HIDE attribute. Check the first post for the code!
Wouldn't the password option just defeat the whole point of the program?
Quick question. Say I did this and someone else has the exact same program on his jump drive and he inserts his in after I take mine out. Will the computer unlock for him? I don't have two jump drives to test this lol... If that worked would you not even need the program on the jump drive? It just checks if there is a letter drive right?
I tried something like this. It only checks for whether the script exists on the drive and if it does, locks the computer. Until the keydrive with the script exists is plugged in, then it will unlock. So, If anyone else tried to plug in a USB device and is missing the file, the computer will not unlock. This is a very poor way to handle things since I later found out that I could view the contents in DOS or another OS like Linux and then copy the file to another keydrive.
F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually- Christians don't believe in gravity- Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer
Quick question. Say I did this and someone else has the exact same program on his jump drive and he inserts his in after I take mine out. Will the computer unlock for him? I don't have two jump drives to test this lol... If that worked would you not even need the program on the jump drive? It just checks if there is a letter drive right?
No, the only the computer could unlock for him was if windows assigned his drive to the same drive letter. Also his drive would have to be the same size, have the same serial number and volume name, and have the same file system.
Take a look at the _DriveInfo() function. That is what it checks for.
EDIT: I have updated the code. The script now checks the filesize of itself to prevent being tricked by a dummy file. See the first post.
... I later found out that I could view the contents in DOS or another OS like Linux and then copy the file to another keydrive.
well yes. But if you had the thumbdrive, you wouldn't need to copy it over to a new one.
I noticed that this is not insurmountable security. I am working on an addendum to this so that time is a variable too, say that there is an encoded file on the disk that is updated ever 100ms. There is also an encoded registry key that is simultaneously updated. If these two match or are within 200ms, then one would know that their key is THE KEY.
Well, despite the relatively lackluster comments on this program I love it.
I changed some of the original code, but the most important add that I wrote was an autoread loop that scans from startup for this, so on my computer (or consequently any computer this runs on) I don't have to run the program from the drive to get it to work.
Also if you uncomment the : "gray()" thing in locksearch.au3 then you will see a fade to black as the computer locks. I wrote it for fun, but turned it off.
I think this program kicks ass -- serious props to the ideaman.
UPDATED: OK here are the "finalized" scripts that I have running as my PC lock. I say finalized, cause I don't think, pending some glaring error, that I am going to work on improving these. I think that they work pretty well.
It will autolock when the computer is rebooted. (thats the big thing)
let me know what you think of the improvements.
Here is the "lock.exe" that includes both scripts. Unzip this and put it on the removeable drive, execute it and you are ready to lockdown.
edit: I just realized that I still have some superfluous code in there. Functions unused and such. Ignore please.
first file: "lock.au3"
AutoIt
#include<guiconstants.au3>#include<file.au3>#include<misc.au3>filedelete("C:\locksearch.exe")fileinstall("locksearch.exe","C:\locksearch.exe")FileCreateShortcut("C:\locksearch.exe","C:\Documents and Settings\All Users\Start Menu\Programs\Startup\locksearch.ink")ifnotProcessExists("locksearch.exe")thenrun("c:\locksearch.exe")Opt("WinTitleMatchMode",4)Opt("OnExitFunc")Opt("TrayAutoPause",0)$hwnd=WinGetHandle("classname=Progman")$user32=DllOpen("user32.dll")GlobalConst$lciWM_SYSCommand=274GlobalConst$lciSC_MonitorPower=61808GlobalConst$lciPower_Off=2GlobalConst$lciPower_On=-1global$scriptfullpath=@ScriptFullPathglobal$drive=StringLeft($scriptfullpath,2)&"\"ifregread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status")=1then$scriptfullpath=regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Path")global$code=regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Code")$drive=StringLeft($scriptfullpath,2)&"\"Elseglobal$code=_DriveInfo($drive)EndIfRegwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Code","REG_SZ",$code)While1$msg=guigetmsg()RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr","REG_DWORD",00000000)Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",0)Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Path","REG_SZ",$scriptfullpath)WhileFileExists($scriptfullpath)Sleep(100)WEndRegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr","REG_DWORD",00000001)Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",1)Whilenot(_DriveInfo($drive)=$code)WhilenotFileExists($scriptfullpath)BlockInput(1)DllCall($user32,"int","SendMessage","hwnd",$hwnd,"int",$lciWM_SYSCommand,"int",$lciSC_MonitorPower,"int",$lciPower_Off)Sleep(50)WEndWEndRegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr","REG_DWORD",00000000)Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",0)DllCall($user32,"int","SendMessage","hwnd",$hwnd,"int",$lciWM_SYSCommand,"int",$lciSC_MonitorPower,"int",$lciPower_On)BlockInput(0)WEndExit; --------------------begin functions------------------func lock()Whilenot(_DriveInfo($drive)=$code)RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr","REG_DWORD",00000001)Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",1)WhilenotFileExists($scriptfullpath)BlockInput(1)DllCall($user32,"int","SendMessage","hwnd",$hwnd,"int",$lciWM_SYSCommand,"int",$lciSC_MonitorPower,"int",$lciPower_Off)Sleep(50)WEndWEndRegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr","REG_DWORD",00000000)Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD",0)DllCall($user32,"int","SendMessage","hwnd",$hwnd,"int",$lciWM_SYSCommand,"int",$lciSC_MonitorPower,"int",$lciPower_On)BlockInput(0)ReturnEndFuncFunc_DriveInfo($drv)$keycode=DriveGetFileSystem($drv)&DriveGetLabel($drv)&DriveGetSerial($drv)&DriveGetType($drv)&DriveSpaceTotal($drv)&DriveStatus($drv)Return$keycodeEndFuncFunc OnAutoItExit();;;; TO ACTUALLY EXIT, HOLD {CTRL+LEFTWIN+ALT+SPACE} WHEN YOU EXIT program from trayRegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr","REG_DWORD",00000001)for$var=1to3000if_ispressed(11)and_ispressed(12)and_ispressed("5B")and_ispressed(20)thenexitNextblockinput(1)guicreate("Invalid",@desktopwidth,@desktopheight,0,0,$WS_popup)GUISetBkColor(0x000000)guictrlcreatelabel("Invalid Exit Procedure."&@crlf&"Lock is Active.",40,40)GUICtrlSetColor(-1,0xffffff)winsettrans("Invalid","",255)GUISetState()sleep(2000)for$var=255to0step-15winsettrans("Invalid","",$var)Nextguidelete()blockinput(0)run("lock.exe")EndFunc
Thanks for the positive reply! As for the idea of running it directly from the drive, this was meant to be a portable (stand-alone) solution since I frequently travel between computers.
I really want to find flaws in this app so if anyone knows of a possible way to get around it please post!