Automatic Defragmentation

Defragmentation can be easily fully automated. Just check Automatic defragmentation on the components selection page during the installation and the program will automatically defragment your disks from time to time.

To adjust defragmentation schedule on Windows Vista and more recent Windows editions click Settings > Automatic defragmentation > Scheduler in UltraDefrag GUI or go to Start > Control Panel > Administrative Tools > Task Scheduler, then navigate to the Task Scheduler Library\UltraDefrag\AutoDefrag task and edit its properties.

To adjust the schedule on Windows XP and Server 2003 click Settings > Automatic defragmentation > Scheduler in UltraDefrag GUI or go to Start > All Programs > Accessories > System Tools > Scheduled Tasks, then select the AutoDefrag task and edit its properties.

To adjust defragmentation options click Settings > Automatic defragmentation > Script in UltraDefrag GUI or edit the following file manually: {installation folder}\tasks\auto-defrag.cmd.

By default the program executes the following script once a day when the computer is idle:

@echo off
::
:: UltraDefrag uses this script for automatic defragmentation.
:: Feel free to adjust it to make it more suitable for your needs.
::
:: Visit https://en.wikibooks.org/wiki/Windows_Batch_Scripting
:: to learn more about the script syntax and available commands.
::
:: For syntax highlighting open this file in Notepad++ editor
:: (http://www.notepad-plus-plus.org/).
::
:: first of all, let's set UD_EX_FILTER to exclude all
:: the stuff which rarely benefits from defragmentation
:: exclude temporary content
set UD_EX_FILTER=*system volume information*;*temp*;*tmp*;*recycle*
set UD_EX_FILTER=%UD_EX_FILTER%;*dllcache*;*ServicePackFiles*;*.log
:: exclude archives
set ARCHIVE_PATTERNS=*.7z;*.7z.*;*.arj;*.bkf;*.bz2;*.bzip2;*.cab;*.cpio;*.deb
set ARCHIVE_PATTERNS=%ARCHIVE_PATTERNS%;*.dmg;*.gz;*.gzip;*.lha;*.lzh;*.lzma
set ARCHIVE_PATTERNS=%ARCHIVE_PATTERNS%;*.rar;*.rpm;*.swm;*.tar;*.taz;*.tbz
set ARCHIVE_PATTERNS=%ARCHIVE_PATTERNS%;*.tbz2;*.tgz;*.tpz;*.txz;*.xar;*.xz
set ARCHIVE_PATTERNS=%ARCHIVE_PATTERNS%;*.z;*.zip
set UD_EX_FILTER=%UD_EX_FILTER%;%ARCHIVE_PATTERNS%
:: exclude multimedia content
set AUDIO_PATTERNS=*.aif;*.cda;*.flac;*.iff;*.kpl;*.m3u;*.m4a;*.mid
set AUDIO_PATTERNS=%AUDIO_PATTERNS%;*.mp3;*.mpa;*.ra;*.wav;*.wma
set VIDEO_PATTERNS=*.3g2;*.3gp;*.asf;*.asx;*.avi;*.flv;*.mov;*.mp4
set VIDEO_PATTERNS=%VIDEO_PATTERNS%;*.mpg;*.rm;*.srt;*.swf;*.vob;*.wmv
set UD_EX_FILTER=%UD_EX_FILTER%;%AUDIO_PATTERNS%;%VIDEO_PATTERNS%
:: exclude virtual machines
set DISK_IMAGE_PATTERNS=*.fat;*.hdd;*.hfs;*.img;*.iso;*.ntfs;*.squashfs
set DISK_IMAGE_PATTERNS=%DISK_IMAGE_PATTERNS%;*.vdi;*.vhd;*.vmdk;*.wim
set UD_EX_FILTER=%UD_EX_FILTER%;%DISK_IMAGE_PATTERNS%
:: exclude big fragments which rarely benefit from defragmentation
set UD_FRAGMENT_SIZE_THRESHOLD=20MB
:: if your system drive is an SSD uncomment the following
:: line to exclude slightly fragmented content as well
:: set UD_FRAGMENTS_THRESHOLD=20
:: uncomment the following line to increase amount of debugging output
:: set UD_DBGPRINT_LEVEL=DETAILED
:: defragment system drive
set UD_LOG_FILE_PATH=%UD_INSTALL_DIR%\logs\autodefrag-system.log
udefrag --wait %SystemDrive%
:: defragment heavily fragmented content
:: on all the connected non-removable drives
set UD_LOG_FILE_PATH=%UD_INSTALL_DIR%\logs\autodefrag-fixed.log
set UD_FRAGMENTS_THRESHOLD=20
udefrag --wait --all-fixed
Note
By default the script won't be executed when the computer runs on batteries.

Additionally, to prevent waste of time the program disables the following built-in task on Windows Vista and more recent Windows editions:
Task Scheduler Library\Microsoft\Windows\Defrag\ScheduledDefrag.