Automatic defragmentation preferences

Last updated on Jun 7, 2022

On the Automatic defragmentation tab of the preferences dialog you can set the disks to be processed automatically and access the schedule. Also you can disable the automatic defragmentation completely or set a custom script for it.

If you will select the custom script to be executed, UltraDefrag will use the following batch script to perform the automatic defragmentation: %UD_INSTALL_DIR%\tasks\auto-defrag-custom.cmd. The main advantage of the custom script is that you can easily automate complex defragmentation tasks using it. By default the script defragments the system disk and heavily fragmented files on all the connected non-removable disks using the command line interface of UltraDefrag. Check the UltraDefrag CLI article for the complete information about all the available commands and script samples.

By default UltraDefrag performs the selected action once a day when the computer is idle and not running on batteries. To adjust the schedule click Schedule, then navigate to the Task Scheduler Library > UltraDefrag > AutoDefrag task and edit its properties.

The General tab of the properties dialog contains general settings of the task. Do not modify them unless you know exactly what you are doing, as setting inappropriate options will prevent defragmentation from being performed.

On the Triggers tab of the dialog you can specify the conditions that will trigger automatic defragmentation.

By default the task starts at 6 PM every day. To adjust the schedule select the Daily trigger and click Edit. You can set the task to be executed daily, weekly or monthly, select the days of the week and set the startup time. Also you can randomly delay the task, repeat it and stop the task if its execution takes too long.

The Actions tab of the task properties dialog sets a command to be executed when the task starts. Do not modify the command unless you know exactly what you are doing.

On the Conditions tab of the task properties dialog you can specify additional conditions that determine, along with the trigger, when the task will be performed.

By default the task starts when the computer is idle for 3 minutes.


Windows Vista and 7 do check whether the computer is idle or not quite infrequently, every 15 minutes or so. Thus, on those systems the task may take up to 15 minutes of idle time to start.

If the computer ceases to be idle before the task completion, the task will be stopped and resumed later when the computer will be idle again. Also, by default the task will be performed only when the computer is not running on batteries. UltraDefrag does not wake the computer to run the task by default, but you can easily enable that on this tab, if you wish.

And, finally, on the Settings tab you can specify additional settings that affect the behavior of the task.

The Allow task to be run on demand option is useful for troubleshooting as it allows the task to be started directly from the Task Scheduler.

Also on the settings tab you can limit the task execution time and set what needs to be done if the task is already running. By default the task execution time is unlimited and if the task is still running when time comes to run the task again the new task will be enqueued for execution, i.e. it will be executed when the running task finishes its job.

To check whether the task is set properly or not, let the task run and then check the last run result in Task Scheduler. The most common last run results are:

Last run resultMeaning
The operation completed successfully. (0x0)The task completed successfully.
The process terminated unexpectedly (0x8007042B)The task has been stopped because the computer ceased to be idle and will be resumed later when the computer will be idle again.

More last run results along with their meaning can be found on Microsoft’s website.

Share this page:
Scroll to Top English