How to automatically start screensaver when locking Windows

In order to automatically start a screensaver when you lock your computer (ie. using the WIN + L shortcut key combination), you have to follow these steps:

  1. Using Notepad, add the following two lines:
    C:\Windows\system32\SCREENSAVER.scr -s
    C:\Windows\System32\rundll32.exe user32.dll, LockWorkStation

    You should replace SCREENSAVER.scr with an actual screen saver name, by searching the “C:\Windows\system32\” directory for files with “.scr” extension. A working example is the following:
    C:\Windows\system32\PhotoScreensaver.scr -s
    C:\Windows\System32\rundll32.exe user32.dll, LockWorkStation
  2. Save the file with a “.bat” extension, for example name it “ScreenSaver.bat”.

Note: After you have created the file, you can create a shortcut of it on your Desktop (you can optionally hide it) in order to use a shortcut key combination, such as Ctrl + Alt + S.