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
cleanmgrto reclaim space on a schedule. - Validate execution history and adjust triggers, conditions, and security options.
Part 1: Console Orientation
- Press Windows and search for Task Scheduler; launch the MMC snap-in.
- 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.
- 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
- In the actions pane, choose Create Basic Task…. Name it Launch Lab Notepad and provide a short description.
- Select a trigger schedule such as Daily, starting a few minutes from now so you can observe execution during the lab.
- For the action, select Start a program and browse to
C:\Windows\System32\notepad.exe(or another application you want to test). - Finish the wizard, then right-click the task and choose Run to validate it launches immediately.
- Check the History tab to confirm Task Scheduler recorded the manual run; enable history if prompted.
Part 3: Prepare Disk Cleanup Settings
- Open an elevated Command Prompt and run
cleanmgr.exe /sageset:11. This stores cleanup preferences under state ID 11. - In the Disk Cleanup settings dialog, select categories safe for automated removal (Temporary files, Thumbnails, Windows Update Cleanup, etc.) and click OK.
- Verify the settings by optionally running
cleanmgr.exe /sagerun:11once; this uses the profile you just defined.
Part 4: Schedule Automated Disk Cleanup
- Back in Task Scheduler, click Create Task… (not the basic wizard) so you can fine-tune security. Name it Weekly Disk Cleanup.
- Under the General tab, select Run whether user is logged on or not and tick Run with highest privileges so elevated cleanup can succeed.
- 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.
- On the Actions tab, add a new action: Start a program with
cleanmgr.exeas the program and/sagerun:11as the argument. - (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.”
- 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>andcleanmgr.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
/sagesetand verified with/sagerun. - Weekly Disk Cleanup task runs with elevated privileges and stores history.
- Task export or screenshot captured for lab documentation.