Boot time interface overview

Last updated on Jun 1, 2021

UltraDefrag includes a special boot time interface which purpose is to perform defragmentation and optimization of locked files during a system reboot, before Windows and applications fully load and lock the files.

Notes

  • Non-system disks encrypted by BitLocker cannot be processed at boot time because there is no way to unlock them on early stages of Windows boot. We do recommend to turn off the disk encryption temporarily before the disk processing and turn it back on afterwards.
  • The boot time interface cannot be used in Windows safe mode, because it cannot display text on the screen in this mode, due to a well known system limitation.
  • The boot time interface is not available in the portable edition of UltraDefrag.

Check the following articles to learn how to use the boot time interface of UltraDefrag to perform typical defragmentation tasks:

Another interesting feature of the boot time interface of UltraDefrag is that you can write a custom script for it or even use it interactively. Follow this step by step guide to learn how to do it:

  1. Launch UltraDefrag and click Action > Boot time defragmentation > Edit custom script.

    Alternatively, you can open the following file manually in your favorite text editor: %SystemRoot%\system32\ud-boot-time-custom.cmd.

  2. Paste the following content to the script and then save it:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    @echo off
    ::
    :: A custom boot time script example.
    ::
    :: This script optimizes the master
    :: file table (MFT) on the system disk.
    ::
    :: Please note, you have to save this script
    :: in Unicode (UTF-16 / UCS-2 LE BOM) encoding.
    ::

    :: turn the boot time defragmentation off for subsequent boots

    boot-off

    :: optimize the master file table on the system disk

    udefrag --optimize-mft %SystemDrive%

    :: pass control back to the Windows boot process

    exit
  3. Click Action > Boot time defragmentation > Execute custom script.

  4. Click Reboot now to proceed with the boot time script execution immediately or Reboot later to perform it at the next system reboot.

  5. During the system reboot UltraDefrag will launch its boot time interface and execute the custom script.

    UltraDefrag 9.0.1 boot time interface.
    Copyright (c) 2018-2019 Green Gate Systems, LLC.

    UltraDefrag comes with ABSOLUTELY NO WARRANTY.

    If something is wrong, hit F8 on startup
    and select 'Last Known Good Configuration'
    or execute 'CHKDSK {Drive:} /R /F'.

    Keyboard device found: \Device\KeyboardClass0.

    Wait for keyboard initialization (hit Esc to skip) .......... [Done]

    Keyboard device found: \Device\KeyboardClass0.

    Press any key to exit .....

    Preparing to optimize MFT on disk C: ...
    Use Pause/Break key to abort the process early.

    Optimization: 100.00%, fragmented/total=0/1009398

    Drive information:

      Total space                 = 118.12 GB
      Free space                  = 15.77 GB

      Total number of files       = 1009398
      Number of fragmented files  = 0
      Fragments per file          = 1.00
      Fragmentation               = 0.00%

    Good bye...

  6. That’s about it! Now it’s time to learn about the available commands and environment variables, check a few more boot time script examples and, finally, write your own custom script 😉

Interactive console

If you will omit the exit command in the script, UltraDefrag will show an interactive boot time console after the script execution:

Interactive mode:
Type 'help' to list available commands.
#

The interactive console is very useful for the script syntax and commands learning, as you can enter commands one by one and check how they work before writing your own custom boot time script.

Also you can drop yourself into the console at any time during the script execution by hitting the Esc key on the keyboard.

Script syntax

UltraDefrag uses a batch-like syntax for the custom boot time scripts. Lines starting with either :: or ; or # are comments. All other lines start with a command name followed by optional arguments. If the @ sign preceeds a command name the command line interpreter will not display the command before its execution.