First steps with UltraDefrag CLI

Last updated on Jul 3, 2021

UltraDefrag CLI is a powerful command line interface of UltraDefrag. It is a complete alternative to the graphical interface – for any action you might want to perform in the graphical interface there is an equivalent command.

The main advantage of UltraDefrag CLI is that you can easily automate complex defragmentation tasks using it. All you need to do is to write a batch script and set it as a custom script for the automatic defragmentation component of UltraDefrag.

Note

To set UltraDefrag specific environment variables according to the user preferences, display the file fragmentation reports and enqueue disks for the boot time defragmentation from the command line download UltraDefrag Supplementary Scripts and put them to the installation directory of UltraDefrag.

Also UltraDefrag uses its command line interface for the one-click defragmentation of individual files and folders. Whenever you select a file or a folder in Windows Explorer and select Defragment with UltraDefrag from the context menu UltraDefrag launches the udefrag command, the core component of UltraDefrag CLI, to perform the task.

Follow this step by step guide to explore all the available UltraDefrag CLI commands and get an idea of what can be accomplished using them.

  1. Open an elevated command prompt.

  2. Type cd %UD_INSTALL_DIR% to navigate to the installation directory of UltraDefrag.

    C:\WINDOWS\system32>cd %UD_INSTALL_DIR%

    C:\Program Files\UltraDefrag>
  3. Type setenv to set the UltraDefrag specific environment variables according to the user preferences.

    C:\Program Files\UltraDefrag>setenv
  4. Type udefrag -la to show the list of disks available for defragmentation.

    C:\Program Files\UltraDefrag>udefrag -la

    UltraDefrag 9.0.1, Copyright (c) 2018-2019 Green Gate Systems, LLC.
    This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND.

    Disks available for defragmentation:

    Drive     FS     Capacity       Free   Label
    --------------------------------------------
    C:      NTFS    118.12 GB       12 %   Acer
    E:      NTFS      1.81 TB       36 %   Elements
  5. Type udefrag -a c: to analyze the disk C:

    C:\Program Files\UltraDefrag>udefrag -a c:

    UltraDefrag 9.0.1, Copyright (c) 2018-2019 Green Gate Systems, LLC.
    This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND.

    c: analysis: 100.00%, fragmented/total = 371/1010131
  6. Type udefrag c: to defragment the disk.

    C:\Program Files\UltraDefrag>udefrag c:

    UltraDefrag 9.0.1, Copyright (c) 2018-2019 Green Gate Systems, LLC.
    This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND.

    c: defragmentation: 100.00%, 4 passes, fragmented/total = 3/1010179
  7. Type show-report c: to display the list of fragmented files.

    C:\Program Files\UltraDefrag>show-report c:

    ;---------------------------------------------------------------------------------------------
    ; LAPTOP-FHEFQMJJ: : Fragmented files on C: [02/11/21 12:10:02]
    ;
    ; Fragments    Filesize  Comment      Status    Filename
    ;---------------------------------------------------------------------------------------------

             21        8 GB       -       locked    C:\pagefile.sys
              6      714 MB       -           -     C:\$MFT
              3      272 MB       -       locked    C:\swapfile.sys
  8. Type udefrag --optimize-mft c: to optimize the master file table on the disk.

    C:\Program Files\UltraDefrag>udefrag --optimize-mft c:

    UltraDefrag 9.0.1, Copyright (c) 2018-2019 Green Gate Systems, LLC.
    This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND.

    c: optimization: 100.00%, fragmented/total = 2/1010179
  9. Type bt udefrag c: to defragment all the locked files on the disk using the boot time interface of UltraDefrag.

    C:\Program Files\UltraDefrag>bt udefrag c:

    Boot time defragmentation requires a system reboot.
    R - Reboot now, L - Reboot later, C - Cancel [R,L,C]?

    Press R to proceed with the boot time defragmentation immediately or L to delay it till the next system reboot.