21

If my laptop is plugged in I want closing the lid to automatically lock the computer, without putting it to sleep. I don't see an option to do this in Power Options:

Power screen

Is there a hack to achieve this?

  • 6
    This is generally a bad idea: your laptop dissipates a good deal of heat through the keyboard, and if you leave the computer running with the lid closed, you risk overheating things. – Mark Apr 12 at 21:23
  • 17
    @Mark: ...and yet you can set it to keep running full blast when you close the lid, without frying anything. – Sean Apr 13 at 3:26
20

As far as I know, there is no built-in function to achieve this. But you can do this using a third party tool.

One of them is LapLock. This program is a lightweight (<50KB), open source tool and it's developed by Etienne Dechamps.

Steps...

  1. Download the program - https://github.com/dechamps/laplock/releases
    (Download the latest laplock.exe release)

  2. Open the Windows Startup folder by using this run command - 'shell:common startup'

  3. Add laplock.exe to your Startup folder.

You can also use Lid Lock to do this.

18

Set "Do Nothing", lock your laptop using Windows key+L, and then you can close the lid.

  • 15
    This is the most practical solution. I am always suspicious of any software that chooses to customize something which Windows has built in. I'm looking at you pre-installed "WiFi Booster/manager" crapware! – MonkeyZeus Apr 12 at 19:09
  • 1
    It would seem this should be something you can configure in the registry (if not, Microsoft should make it so). – Jonathan Apr 12 at 20:40
  • 15
    OP: I want closing the lid to automatically lock the computer so this doesn't answer the question. – Agent_L Apr 13 at 15:39
  • 6
    Please do NOT upvote an answer without reading it carefully. This does NOT answer the question and should be DOWN voted (and I would be willing to bet the OP knows he can manually lock his computer before closing the lid) . The site's value diminishes for everyone if we push non-answers to the top by upvoting them. – Jon Bentley Apr 14 at 17:16
  • 3
    I'm downvoting this answer because it does not answer the question "how to automatically lock the computer" – BurnsBA Apr 15 at 1:35
8

Two steps:

  • Capture the close lid event.
  • Trigger a lock-screen event.

See: Capturing laptop lid closing event in windows?, and Command-line (cmd) command to lock a windows machine.

From those sources, we can use RegisterPowerSettingNotification and GUID_LIDSWITCH_STATE_CHANGE to detect the trigger, and run:

rundll32.exe user32.dll,LockWorkStation 

from the command line to send a lock screen request to the machine.

I don't know what compilers you have available, or what languages you know, but this information should help you set up a program to do it for you.

I don't use Windows myself, so I can't build or test it for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.