Create a USB key for your PC

At companies, government institutions and hospitals you see employees with a card unlock their computer. Handy, so we want that too! But then for free and without special hardware. In this article you can read how to automatically log in to Windows by inserting a USB stick. Are you pulling the stick out? Then your system will lock automatically. A kind of USB key, so!

access key

To turn a standard USB stick into an access key for Windows, you need Rohos Logon Key Free. Insert a USB stick and start Rohos Logon Key. click on Configure usb key and set the key. You will be asked for your password. Remove the USB stick and restart your computer. As soon as you have the welcome screen in front of you, insert the USB stick and you will be automatically logged in.


It is more difficult to automatically lock your computer when removing the stick. We make our own script for this. To check whether the stick is still present in your computer, we use an identification file. This can be any file present on your stick. In our example, the USB stick has the drive letter E: and we create the identification file control-file.txt. Then open Windows Notepad and copy the script from the screenshot. Save the script as a cmd file in the folder C:\Scripts, for example as locked-in-missing-usb-stick.cmd.

To lock up

The script works simply. The beginning of the loop is indicated by :Start. With the rule If NOT exist e:\control-file.txt checks if the control file is unreachable. This is the case if the stick is no longer present in your computer. With the command rundll32.exe user32.dll, LockWorkStation your system will be locked. Timeout 10 is a delay. For example, if you make a mistake in the script, you have ten seconds to abort the script with the key combination Ctrl+C. With the last lines goto start send the script back to the beginning and the check is run again.

Now let the script start automatically with your computer, for example via Schedule tasks. Experts can run the script minimized in the system tray, using the NirCmd utility. Then add the command nircmd win min process cmd.exe to your script to minimize the script window.

Recent Posts