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
Open Notepad and copy the following into a new file.
LockScreen.bat@ECHO OFF ECHO. ECHO Locking screen in 4 seconds. ECHO. TIMEOUT 4 rundll32.exe user32.dll, LockWorkStation
- You can change the timeout from 4 seconds to any length of time you want.
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.
- Decide which mechanism you want to use to run the script.
- The startup folder is a good and simple choice if you want to secure your computer after an automatic login.
- All you have to do is save the file in your startup folder and it will run every time you log in.
- In Windows 10, that location is C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
- Task Scheduler allows for more flexibility, but is more difficult to set up.
- Set up a scheduled task to run on your desired trigger.
- Add an action to "Start a program" and browse for your .bat file.
- The startup folder is a good and simple choice if you want to secure your computer after an automatic login.
Related articles