There may be times when you want your computer to lock automatically after login. Here's a way to get that done.

Step-by-step guide

Add the steps involved:

  1. Open Notepad and copy the following into a new file.

    @ECHO OFF
    ECHO.
    ECHO Locking screen in 4 seconds.
    ECHO.
    TIMEOUT 4
    rundll32.exe user32.dll, LockWorkStation
  2. You can change the timeout from 4 seconds to any length of time you want.

  3. Save the file and name it LockScreen.bat.

    Make sure to set "Save as type:" to All Files!

    Depending on how the script will run, you may want to save it to C:\LockScreen.bat rather than in your user folder.





     

  4. Decide which mechanism you want to use to run the script.
    1. The startup folder is a good and simple choice if you want to secure your computer after an automatic login.
      1. All you have to do is save the file in your startup folder and it will run every time you log in.
      2. In Windows 10, that location is C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
    2. Task Scheduler allows for more flexibility, but is more difficult to set up.
      1. Set up a scheduled task to run on your desired trigger.
      2. Add an action to "Start a program" and browse for your .bat file.

 

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.

Related issues