|  | UltraDefrag Handbook 7.1.2

Boot Time Defragmentation

To defragment files locked most of the time UltraDefrag can be launched inside of the Windows boot process. Being executed there UltraDefrag can defragment almost everything including paging and hibernation files.

To enable the boot time defragmenter click Settings > Boot time scan > Enable in UltraDefrag GUI. To configure it click the Script submenu or edit the following file manually: %SystemRoot%\system32\ud-boot-time.cmd.

The following command line tools can be used as well to control it: boot-on, boot-off and boot-config.

Being enabled the boot time defragmenter will run at every boot. However, you may skip its execution, just press any key when the appropriate prompt will be shown on the screen. To stop any disk operations later hit Pause/Break.

# Interactive mode

Hit Escape at any time to drop into an interactive console. It will show the following prompt on the screen and wait for your input:

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

The same interactive console will be shown on the screen after the boot time script execution if the exit command is missing there.

# Available commands

; or #
  Lines starting with one of these characters are treated as comments.

@
  Lines starting with this character will be not shown on the screen.

boot-on
  Turns the boot time defragmenter on for the next boots.

boot-off
  Turns the boot time defragmenter off for the next boots.

call
  Similar to the DOS command. Executes a script; if none is specified the main boot time script will be executed.

echo
  Similar to the DOS command. Displays a message, an empty line, sets whether the commands will be shown on the screen or not or displays the current setting.

exit
  Similar to the DOS command. Terminates UltraDefrag.

help
  Lists all available commands.

hexview
  Displays a file in a HEX viewer layout:

      000000C0: 0a 00 3b 00 20 00 46 00 |   ;   F
      000000C8: 72 00 61 00 67 00 6d 00 | r a g m
      000000D0: 65 00 6e 00 74 00 65 00 | e n t e

history
  Lists all manually entered commands. To cycle through them use the up/down arrow/cursor keys.

man
  Lists or displays available manual pages.

pause
  Pauses the script execution for the specified time interval (in milliseconds) or till a key is pressed if no duration is specified. For example, the command pause 1000 will pause execution for one second.

reboot
  Reboots the computer.

set
  Similar to the DOS command. Lists, sets and clears environment variables.

shutdown
  Shuts the computer down.

type
  Similar to the DOS command. Displays a file; if none is specified the main boot time script will be shown.

udefrag
  The boot time equivalent of the Console Interface. Accepts the following command line switches: -l, -la, -a, -o, -q, --optimize-mft, --all, --all-fixed. To process single files or directories specify their absolute paths. If they include spaces enclose them by double quotes:
  udefrag "C:\Documents and Settings\*" C:\WINDOWS\WindowsUpdate.log

All commands displaying long lists (help, hexview, history, man, set, type) are splitting them into pages in the interactive mode.

# Environment variables

Environment variables can be used the same way as in Windows batch files.

Two special variables are supported: DATE for the current date in the format YYYY-MM-DD and TIME for the current time in the format HH-MM:

    2012-02-14
    12-48

# Restrictions

Encrypted disks cannot be defragmented at boot time because the local security service is inactive on early stages of Windows boot.

UltraDefrag terminates immediately in Windows safe mode because it cannot display text on the screen there.

# Script samples

By default the program defragments the Windows folder, registry hives, paging and hibernation files using the following script:

@echo off
;------------------------------------------------------------------------------
; UltraDefrag Boot Time Shell Script
;------------------------------------------------------------------------------
; !!! NOTE: THIS FILE MUST BE SAVED IN UNICODE (UTF-16) ENCODING !!!
;------------------------------------------------------------------------------
set UD_IN_FILTER=*windows*;*winnt*;*ntuser*;*pagefile.sys;*hiberfil.sys
set UD_EX_FILTER=*temp*;*tmp*;*dllcache*;*ServicePackFiles*
; 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
; uncomment the following line to save debugging information to a log file
; set UD_LOG_FILE_PATH=%UD_INSTALL_DIR%\logs\ud-boot-time.log
udefrag %SystemDrive%
boot-off
exit

The next script utilizes special environment variables mentioned above:

; create a timestamped log file
set UD_LOG_FILE_PATH=%UD_INSTALL_DIR%\logs\ud-boot-time-%DATE%-%TIME%.log
udefrag %SystemDrive%
exit