1. Home
  2. /Hands-on Labs
  3. /Windows Task Scheduler Lab

Windows Task Scheduler Lab

Practice creating scheduled tasks in Windows 11, including a recurring maintenance job that runs Disk Cleanup automatically.

Lab Objectives

  • Launch Task Scheduler and explore the MMC console layout (tree, actions, task list).
  • Create and test a basic scheduled task that opens a custom script or application.
  • Configure an automated Disk Cleanup task that leverages cleanmgr to reclaim space on a schedule.
  • Validate execution history and adjust triggers, conditions, and security options.

Part 1: Console Orientation

  1. Press Windows and search for Task Scheduler; launch the MMC snap-in.
  2. Expand Task Scheduler Library and note the structure: high-level folders on the left, task list in the center pane, and the actions pane on the right.
  3. Browse existing Microsoft-supplied tasks (e.g., under Microsoft > Windows > TaskScheduler) to see how triggers and actions are configured.

Part 2: Create a Custom Task

  1. In the actions pane, choose Create Basic Task…. Name it Launch Lab Notepad and provide a short description.
  2. Select a trigger schedule such as Daily, starting a few minutes from now so you can observe execution during the lab.
  3. For the action, select Start a program and browse to C:\Windows\System32\notepad.exe (or another application you want to test).
  4. Finish the wizard, then right-click the task and choose Run to validate it launches immediately.
  5. Check the History tab to confirm Task Scheduler recorded the manual run; enable history if prompted.

Part 3: Prepare Disk Cleanup Settings

  1. Open an elevated Command Prompt and run cleanmgr.exe /sageset:11. This stores cleanup preferences under state ID 11.
  2. In the Disk Cleanup settings dialog, select categories safe for automated removal (Temporary files, Thumbnails, Windows Update Cleanup, etc.) and click OK.
  3. Verify the settings by optionally running cleanmgr.exe /sagerun:11 once; this uses the profile you just defined.

Part 4: Schedule Automated Disk Cleanup

  1. Back in Task Scheduler, click Create Task… (not the basic wizard) so you can fine-tune security. Name it Weekly Disk Cleanup.
  2. Under the General tab, select Run whether user is logged on or not and tick Run with highest privileges so elevated cleanup can succeed.
  3. On the Triggers tab, add a Weekly trigger (e.g., every Sunday at 02:00). Enable the trigger and allow the task to start as soon as possible after a missed run.
  4. On the Actions tab, add a new action: Start a program with cleanmgr.exe as the program and /sagerun:11 as the argument.
  5. (Optional) On the Conditions tab, require AC power for laptops; on Settings, enable “Run task as soon as possible after a scheduled start is missed.”
  6. Save the task, supply administrator credentials if prompted, then right-click and choose Run to confirm it executes and logs completion in the History tab.
Quick Reference
  • Task Scheduler MMC: taskschd.msc
  • Create task CLI: schtasks.exe /create
  • Disk Cleanup profiles: cleanmgr.exe /sageset:<ID> and cleanmgr.exe /sagerun:<ID>

Remember that schtasks.exe supports export/import. Capture your Disk Cleanup task with schtasks /query /tn "Weekly Disk Cleanup" /xml > diskcleanup.xml to reapply settings elsewhere.

Completion Checklist
  • Custom "Launch Lab Notepad" task created, tested, and logged.
  • Disk Cleanup profile configured with /sageset and verified with /sagerun.
  • Weekly Disk Cleanup task runs with elevated privileges and stores history.
  • Task export or screenshot captured for lab documentation.