bulletThe ID Security Suite News Archive is being updated on regular basis, so please check in from time to time for up to date articles on PC Security issues.

Step 1 – Open a DOS promot for launching a special command line. One simple way you can do it would be by clicking Start/Run, typing CMD.

Step 2 – EnterĀ  the command line for locking your station:

rundll32.exe user32.dll, LockWorkStation

and your computer will be locked.

Lock computer using command like

Published: 11 Aug 2008  by Cristina Mailat, in: Protection, Tutorials Tags: , , RSS feed for comments on this post.

23 Responses to “How to lock your computer using command line”

  1. how to unlock ? ?

  2. The information was very useful for me and helped me to develop a small tool which I hope will be very useful in my work.

  3. How to unlock ..?

  4. do yopu think i can make a batch of this?

  5. To unlock the stations just re-enter the username and password for the locked profile, this command is very useful when using remote software when you don’t have other means of locking the station being worked on.

  6. will it work in windows 7??…if not wt to do for windows 7???

  7. The application will work the method with the bat file depending on the rights on the system.

  8. rundll32.exe is a windows-based dynamic library link…of course it will work on windows

  9. …how to unlock?…
    press CTRL ALT DEL and log in just like normal…. :0)

  10. windows key + l also works and is much faster and easier

  11. You unlock by logging in.

    You will ether press Ctrl, Alt and Delete if your using windows Pro or Ultimate or you just click on your Username Icon if your using windows Home

    Then enter your password if you have one.

  12. This will not work on windows7 as-is. It will instead shut windows7 down.

  13. windows key + L works fine, but not if you want another program to enter that command for you. the sendkeys method doesn’t support pressing “windows key + character”.

  14. works for Windows XP not W7 though. thanks.

  15. Re: Windows key+l

    Yea, but that won’t be as helpful as the cmd in case you are running a remote desktop from your PC.

  16. This works just fine for me with windows 7.
    Open Notepad
    Copy and paste this:
    Rundll32.exe User32.dll,LockWorkStation

    then save the file as lock.bat (or whatever as long as at it ends in .bat)
    I put it on the desktop. Double click on the file and the computer locks.

  17. how to unlock it

  18. Thanks, nice tip. Also using it for remote sessions. Tested and works on vista x86
    Another nice tip is using texter (get it from lifehacker.com), add eg. “lock” as trigger and it will type rundll32.exe user32.dll, LockWorkStation for you :)

  19. is possible run this command from remote pc ( of the same lan ) ?

    thanks Alberto

  20. Do you guys know how to unlock it via the same batch file that locks it?

    My scenario is that I want to run some automated tests and the tool requires a “real” window to be opened. I would then unlock the computer, run my scripts and then for security reasons, I want to lock it again.

    Any ideas would be greatly appreciated

  21. Thanks it works :)

  22. Growan Technologies

    Nice post…….
    This is what i was looking from long time…….
    but is there any command to unlock the system??????

  23. My keyboard has some extra buttons that can be customized to run a program I choose. I put in this command as the program, and it works great for one-touch locking of my workstation! Thanks! (For the record, it’s a Logitech MX3000 keyboard on Windows 7 x64 Pro.)

Leave a Reply