Boot Time Defragmentation

UltraDefrag also includes a new mode that allows you to run it at boot time in a manner similar to chkdsk. This is known as a native application. The primary goal of it is defragmentation of locked files. UltraDefrag runs at Windows boot before any file locking, so it can defragment almost everything, including page and hibernation files. View screenshots...

If the boot time defragmenter is enabled, it will run at every boot.

Note
You will have a chance to exit immediately, just press any key when the appropriate prompt is displayed. If no key is pressed during this delay, the boot time script will be executed.

You can always stop the disk analysis/defragmentation by pressing the Pause/Break key on the keyboard.

The following restrictions exist for the boot time scans:

  • You may not scan encrypted disks. This is because lsass.exe, the component of the operating system that reads encrypted disks, is still not loaded at a time of the native applications execution.
  • In Windows Safe Mode the program cannot display text on the boot screen. UltraDefrag checks for boot options and returns immediately, if the Safe Mode flag has been found.

The boot time defragmenter can be enabled/disabled either from the main GUI window or by typing boot-on/boot-off commands in the command prompt.

Boot Time Modes

The boot time defragmenter can be executed in two modes:

Boot time script
The boot time script consists of the disk defragmentation commands, ancillary commands and comments. It is located at %windir%\system32\ud-boot-time.cmd. To edit this file execute boot-config at the command prompt or simply click the Boot time script button on the UltraDefrag GUI toolbar.

The boot time script simplifies also the use of UltraDefrag on computers running Windows 98. After installing Windows XP as a second operating system, UltraDefrag may be installed too. After adding the shutdown command to the boot time script you may simply boot the XP system (which requires much less resources at boot time!) and safely leave your computer. It will be shut down automatically after the job is completed.

To abort the script execution and enter the interactive mode immediately hit ESC at any time during the boot time script processing.
Interactive mode
When the exit command is missing in the boot time script UltraDefrag runs in interactive mode after the last script command is executed. UltraDefrag displays the following command prompt and waits for the users input:
Interactive mode:
Type 'help' for list of supported commands.

#

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

Available Boot Time Commands

; or #
Lines starting with one of these characters are treated as comments.
@
Do not show the command line preceded by the at-sign on the screen. By default the command line is displayed on the screen.
boot-on
Turn on the boot time defragmentation to be executed at every boot.
boot-off
Turn off the boot time defragmentation. It prevents them from being executed at next reboots. Until you will enable them manually through UltraDefrag Configuration dialog or boot-on.cmd script.
call
Similar to the DOS command. Executes the specified script. If no script is specified, the default boot time script is executed.
echo
Similar to the DOS command. Display a message, empty line, enable/disable showing the command line on the screen or display the status of showing the command line.
exit
Similar to the DOS command. Break the boot time program execution and return the specified error code or zero.
help
Show a list of all available commands.
hexview
Display the contents of the specified 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
Show a list of all manually entered commands. To cycle through the commands use the up/down arrow/cursor keys.
man
List or display available manual pages.
pause
Pause the script execution for the specified time interval (in milliseconds, 2147483647 maximum) or till a key is pressed, if no duration is specified. For example, the command pause 1000 will pause execution for one second.
reboot
Reboot the computer.
set
Similar to the DOS command. List, set and clear environment variables. For further information about the supported variables consult the Console Interface page.
shutdown
Halt the computer.
type
Similar to the DOS command. Display the contents of a file, the default is the boot time script.
udefrag
This is the native equivalent of the UltraDefrag command line tool. The following command switches are supported:

-l, -la, -a, -o, -q, --quick-optimize, --optimize-mft, --all, --all-fixed, -r, --repeat

Multiple drive letters on a single command line are allowed.
You can specify absolute paths to process single files or directories. Paths including spaces must be enclosed by double quotes ("). To specify multiple paths separate them by spaces.

Example:
udefrag "C:\Documents and Settings" C:\WINDOWS\WindowsUpdate.log

For further information about the command switches and variables consult the Console Interface page.

When UltraDefrag encounters the wrong syntax it shows an appropriate message on the screen and continues the script execution.

Environment variable expansion

The boot time script and the interactive mode support environment variable expansion. This allows a more flexible script to be written by using %SystemDrive% instead of C:. In addition to the regular variables there are two variables, DATE and TIME, that will be set dynamically. Both are formated to be easily used as part of a file name, so a timestamped log file name can be created.

DATE
This will be expanded to the current date in the format YYYY-MM-DD
echo DATE ... %DATE%
Results in the display of:
DATE ... 2012-02-14
TIME
This will be expanded to the current time in the format HH-MM
echo TIME ... %TIME%
Results in the display of:
TIME ... 12-04

Boot time script example

The following script is used by default:

@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*;*.zip;*.7z;*.rar;*dllcache*;*ServicePackFiles*
; uncomment the following line to create 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\defrag_native.log
udefrag c:
exit

The following script utilizes environment variable expansion:

;--------------------------------------------------------------------
; 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*;*.zip;*.7z;*.rar;*dllcache*;*ServicePackFiles*
;create a timestamped log file
set UD_LOG_FILE_PATH=%UD_INSTALL_DIR%\Logs\defrag_native_%DATE%_%TIME%.log
udefrag %SystemDrive%
exit

Previous: Graphical Interface Next: File Fragmentation Reports