Re-assign/override hotkey (Win + L) to lock windows Re-assign/override hotkey (Win + L) to lock windows windows windows

Re-assign/override hotkey (Win + L) to lock windows


You need to set the following registry key to completely disable the Windows locking feature:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System] "DisableLockWorkstation"=dword:00000001

And restart the computer.

This works on Win7, Win8 and Win10


The Win+L is a system assigned hotkey and there's no option to disable it. This means there's no way for an application to detect it, unless you use a low-level global keyboard hook (WH_KEYBOARD_LL). This works in XP SP3; haven't tested it in Vista though:

LRESULT CALLBACK LowLevelKeyboardProc(int code, WPARAM wparam, LPARAM lparam) {    KBDLLHOOKSTRUCT& kllhs = *(KBDLLHOOKSTRUCT*)lparam;    if (code == HC_ACTION) {        // Test for an 'L' keypress with either Win key down.        if (wparam == WM_KEYDOWN && kllhs.vkCode == 'L' &&             (GetAsyncKeyState(VK_LWIN) < 0 || GetAsyncKeyState(VK_RWIN) < 0))        {            // Place some code here to do whatever you want.            // ...            // Return non-zero to halt message propagation            // and prevent the Win+L hotkey from getting activated.            return 1;        }    }    return CallNextHookEx(0, code, wparam, lparam);}

Note that you need a low-level keyboard hook. A normal keyboard hook (WH_KEYBOARD) won't catch hotkey events.


The registry-based solution on its own completely disables locking the system (even via the Start menu).

Here is a method that actually provides a way to lock the computer without the Win-L chord. Locking can either be done via a shortcut on the taskbar or by pressing them in sequence followed by Enter.

First, create a batch file that can toggle system locking and trigger the lock itself; instructions for doing this are taken from a forum post:

  • Create reg-edit files for turning system locking on or off. This is the same as in Brent Foust's answer.

    • In DisableLockWorkstation.reg:

       Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System] "DisableLockWorkstation"=dword:00000001
    • In EnableLockWorkstation.reg:

        Windows Registry Editor Version 5.00  [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]  "DisableLockWorkstation"=-
  • Run the reg-edit script for disabling the system lock.

  • Create a batch file to toggle the feature using the .reg files:

    regedit /S EnableLockWorkstation.regrundll32.exe user32.dll,LockWorkStationregedit /S DisableLockWorkstation.reg

Now, you can create a shortcut and pin it to the taskbar:

  • Right-click on the batch file and create a shortcut.
  • Right-click on the new shortcut, edit the shortcut properties, and change target to cmd.exe /C "<path>\lock.bat", where <path> is the full path to the lock.bat file.
  • The shortcut should now be pinnable to the taskbar (this is not true prior to manually changing the target); it can be dragged there as normal.
    • (Note that you may also want to change the icon to something like a padlock before pinning the shortcut to the taskbar.)

As mentioned above, once you've completed the above procedure, you should be able to lock the computer using Win, L, Enter in sequence (not as a chord--though see below for a solution using Ctrl-Alt-L as a chord). This is because that sequence is interpreted as follows:

  • Win -- brings up the Start menu, although you don't actually need to wait for it to load
  • L -- searches for the custom lock-script; on my machine, the lock.bat shortcut was always the first L result if it was the only shortcut on my taskbar starting with L. (Verify this before attempting to lock your computer this way!)
  • Enter -- once the search finds an item, it will be launched--i.e. the shortcut will be called, and your computer will lock. You do not need to wait for the search to load; you can quickly press Win, L, Enter in sequence and walk away. The screen will not lock immediately, but it should lock within a few seconds.

Below is a picture of the taskbar shortcut I made (using this icon):

lock.bat taskbar shortcut


EDIT: Using a chord, such as Ctrl-Alt-L

In the comments below, user lub094 suggests a way to assign the shortcut to the chord Ctrl-Alt-L (or whatever shortcut you'd like). I have not taken the time to test this because I've re-enabled the system shortcut, but I assume that it works.

  • Use the built-in shortcut-creation feature to assign the chord:

    enter image description here

  • Place the shortcut itself in the Start Menu folder:

    "C:\Users\ [user_name]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\ [custom_folder]\"