There are ways to do it with the group policy editor, but for those that prefer to use the task scheduler here’s how:

  1. Go to Task Scheduler.
  2. Click on Create Task.
  3. Name it, give it a description.
  4. Check “Run with highest privileges”.
  5. Check “Run whether user is logged on or now.
  6. Go to “Triggers” tab.
  7. Add a new Trigger.
    • Log: System
    • Source: User32
    • Event ID: 1074
  8. Go to “Actions” tab and add whatever you want. Make sure it doesn’t take too long to execute.