Snippet 博客主题

[轉載] 用USB隨身碟當電腦鎖





@echo off


if exist “d:\test.txt” (

goto :1

) else (

echo “key file not found”

rundll32.exe user32.dll LockWorkStation

goto :1

[flipclock ]



o you know that we can use our USB flash drive as computer lock? You need a USB flash drive and a freeware called Log Monitor. This article will discuss the steps to configure them.

Log Monitor

Log Monitor is a freeware that has many usages. I try to go to the author page but i can’t understand the language, but i think most probably the author is a Russian. After playing with this application, i found that it can actually lock our computer and prevent others to login. The theory behind this is very simple. It keep monitoring your USB flash drive, once the file being monitored changed, or you remove the USB flash drive, this application will immediately lock your computer. If you remove your USB flash drive and the login to your computer, this application will immediately lock your computer again. Unless you hold the USB flash drive, else you can’t access that computer.

Step 1

You need to create a .log file in your USB flash drive. The file name can be anything and you can left your content blank. But, my advise is try to type something and make sure no people can get this file. I had create an example log file and will provide the download address at the end of this article.

Step 2

Go to Monitoring and choose Add File:

Lock PC Step2_1

Now, choose the log file that you created, and change the Do Action’s option to If the file has been changed. Please check the Perform action if monitored file does not exist so that this application can lock your computer when you unplug your USB flash drive.

Lock PC Step2_2

After that, switch to Options tab and set the interval to 1 second. This means Log Monitor will keep pulling each 1 second. If you think that this will affect your computer speed, you can set this value to higher.

Lock PC Step2_3

Step 3

Now, go to Actions tab and choose New -> Execute Program. Fill in the parametes below:

Command: C:\Windows\system32\rundll32.exe
Parameters: user32.dll,LockWorkStation
Start in: C:\Windows\system32

Lock PC Step3

Step 4

This is the final step. Go back to the main page and choose Options -> Program Options. At the General tab, check Minimize on start if you want Log Monitor minimize to system try when startup. Next, check the Start on user logon. Be careful, remember to make 1 copy of your log file if you check this. After you check this option, Log Monitor will automatically launch after you login. If you lost the log file, means you can’t control your computer anymore. After everything done, save the settings to your system and try unplug your USB. Your computer will be locked immediately!

You can download the example of log file and the configuration here. You can also download Log Monitor from Freeware-guide.