Site icon Winhelponline

Automatically Turn off Monitor when you Lock your Computer

We saw how to turn off your monitor or put your computer to sleep mode using shortcuts. Also, we explained how to automatically lock the workstation immediately after automatic login to your account.

By default, after you lock your workstation (computer), the display turns off automatically in 1 minute, and the lock screen display off timeout can only be increased. For some users, the 1-minute interval is not sufficient, and they need a mechanism to automatically turn off the monitor immediately after the computer is locked.

In this article, we’ll see how to automatically turn off the monitor automatically when you lock your computer (Win + L).

Automatically Turn off Monitor when you Lock your Computer

Turning off monitor & locking the workstation can be automated using a Windows Batch file. But it won’t help if the computer locks automatically after the screensaver or Sleep timeout. So, we’ll see how to use Task Scheduler Trigger to accomplish the task.

Note: Before proceeding, we’ll need NirCmd or Wizmo utility that can turn off the monitor. Check out the article How to Turn Off Monitor Using Shortcut or Command-line in Windows for a brief overview of these tools and their download links.

Method 1: Using Task Scheduler

This is the preferred method.

  1. Launch Task Scheduler and click on the Create Task option.
  2. Assign a name and description for the task.
  3. Click on the Triggers tab, and click New…
  4. From the dropdown, select On workstation lock, and click OK.

  5. Click on the Actions tab, and click New…
  6. In the Program/script: box, type in the path to nircmd.exe
  7. In the arguments box, type monitor off as the arguments and click OK, OK.

A new scheduled task is now created, which triggers nircmd.exe monitor off command automatically when you lock the computer.

Method 2: Using Audit & Task Scheduler

Here is another way to turn off the monitor automatically, but this is not the preferred method. Windows Pro versions have the Local Security Policy Editor which allows you to audit logon events. First, enable auditing of successful account logon events via Security Policy console. After you enable auditing, every login, logoff, lock and unlock workstation events are recorded in the Windows Event log. In Step 2, we’ll attach a scheduled task for the “lock workstation” event.

Step 1: Enable audit of logon events

  1. Open the Local Security Policy (secpol.msc) console.
  2. Expand Security Settings → Local Policies → Audit Policy
  3. Double-click Audit logon events
  4. Enable the checkbox for Success, and click OK.
  5. Exit Local Security Policy console.

Step 2: Create an Event Trigger for “Lock Workstation” event

After you enable auditing as in Step 1, workstation lock events are recorded in the Security event log as Event ID: 4800. (Unlock workstation event has ID 4801)

  1. Lock the workstation once using Winkey + L and then unlock it.
  2. Open Event Viewer (eventvwr.msc)
  3. Expand Windows logsSecurity
  4. In the middle pane, locate the recent event having the ID 4800.
  5. Right-click on the event, and click Attach Task To This Event
  6. In the next screen, assign a name for the scheduled task and click Next.
  7. In the next screen, the Event ID and source are automatically filled up. Click Next.
  8. In the Action window, click Start a program, and click Next.
  9. In the Program/script: box, type in the path to nircmd.exe
  10. In the arguments box, type monitor off as the parameters and click Next.

A new scheduled task is now created, which will be automatically triggered when you lock the workstation using any method. The new task is stored under Task Scheduler LibraryEvent Viewer Tasks in Task Scheduler. This is because the above task was created via Event Viewer Attach Task To This Event (a.k.a. Event Trigger) option.

Editor’s note: After some time, if you think you no longer want to turn off the monitor when locking the computer, reverse the steps listed under “Step 1” so that your Security event log is not flooded with login/logoff/lock/unlock workstation events. Then, manually delete the scheduled task using Task Scheduler.

Lock Workstation & Turn off Display using Windows Batch file

You can also use a Windows Batch file to lock your workstation & turn off the monitor in a single click. Again, you’ll need NirCmd or Wizmo.

Create a Batch file (say, lock-and-turn-off-monitor.bat) using Notepad with the following contents:

RunDll32.exe user32.dll,LockWorkStation
C:\Windows\nircmd.exe monitor off

Running the Batch file will accomplish the task!

That’s it! Press Winkey + L to lock the workstation now. It will automatically trigger your “Turn off monitor” scheduled task, and your monitor(s) will now turn off automatically!

Exit mobile version