In part 1 and part 2 of this series, we got started with using task scheduler to set up automatic PC maintenance. If you haven’t read those articles yet:
Now that we’ve instructed task scheduler to start a program at a particular time, let’s tell it what actions we want to be taken.
Step four: one of the most important steps. We are going to specify the location of the program that we want to start. In the Program/script box insert the route of the executable, you can click on browse and navigate through the folders to locate it.
In this case, to execute the windows defrag tool, the path is:
Also, we can add arguments that will specify rules and preferences that the program will follow upon execution.
These are the arguments that we can add to defrag.exe. Those in red work in Windows 8, 8.1 and 10.
/A Perform analysis on the specified volumes.
/B Perform boot optimization to defrags the boot sector of the boot volume. This will not work on an SSD.
/C Perform the operation on all volumes.
/D Perform traditional defrag (this is the default).
/E Perform the operation on all volumes except those specified.
/H Run the operation at normal priority (default is low).
/K Perform slab consolidation on the specified volumes.
/L Perform retrim on the specified volumes. Only for an SSD.
/M Run the operation on each volume in parallel in the background.
/O Perform the proper optimization for each media type.
/T Track an operation already in progress on the specified volume.
/U Print the progress of the operation on the screen.
/V Print verbose output containing the fragmentation statistics.
/X Perform free space consolidation on the specified volumes.
Step five: almost there! The last window shows us a summary of the task that we’ve just created. Make sure that you check the box “Open the Properties dialog for this task when I click Finish”.
Step six: the properties window. Here we’ll set some important privileges options. Always make sure that you are logged with an account that has administrator rights when creating the task, if not, then you can change the account that is running the task from “Change User or group” button (red rectangle). Also check the box “Run with highest privileges” (blue rectangle), if you don’t, some tasks won’t run at all. Last but not least, configure the task for the operative system you are running, in this case, Windows 7 (green rectangle).
Now you can close the window and look for your new task in the Active task section.
But how can we now that it will work when the time comes? Well, if you double-click on it, then you can check and edit its properties from the actions column on the right. There you can run the task anytime you want, end it if it’s already running or delete it if you no longer need it.
Let’s test it by clicking Run.
It’s alive! Click Ctrl+C if you don’t want to run the defrag now.
Now, at the beginning of this series, I promised you some bonus tips for scheduling other actions using Task Scheduler. We’ll check those out in the final part of this series, tomorrow.
~ Hernan Escalante