Table of Contents
The console application is called udefrag.exe. It is placed in system32 directory by the installer. Therefore you can call it from the command line or run box without specifying the full path. The program accepts a lot of useful options: you can perform any disk defragmentation job using this tool.
Usage:
udefrag [command] [options] [volumeletter:]
| ||||||||||||||||||||||||||||||||
Specifying just the drive letter will cause UltraDefrag to defragment the drive. If you abort the operation with Ctrl+C or close the shell window, UltraDefrag will exit safely without destroying any data.
II. udefrag -l command in action:Command promptMicrosoft Windows XP [5.1.2600] (C) Microsoft Corporation, 1985-2001. C:\>udefrag -a c:UltraDefrag v3.2.0, Copyright (c) Dmitri Arkhangelski, 2007-2009. UltraDefrag comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. c: analyse: 100% complete, fragmented/total = 916/16298C:\>_
III. Cluster map customization example:Command promptMicrosoft Windows XP [5.1.2600] (C) Microsoft Corporation, 1985-2001. C:\>udefrag -lUltraDefrag v3.2.0, Copyright (c) Dmitri Arkhangelski, 2007-2009. UltraDefrag comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.Volumes available for defragmentation: C: NTFS 3.92 Gb 6 % D: NTFS 9.42 Gb 3 % E: FAT32 59.30 Gb 5 %C:\>_
Note that files excluded by filters are treated here always as unfragmented. Because trash is unimportant anyway and it should not take an attention.
To set defragmenter options you should use the Environment Variables. To set each of them you can simply type in command line set VarName=Value where VarName is a name of the environment variable and Value is a string to be assigned to the specified variable. The good practice is to store such commands in a batch script before udefrag.exe calls. That will save a lot of your time. This practice will be discussed below. Here is a list of defragmentation related environment variables with a full explaination:
| ||||||||||||||||||
Notes about filter:
The console application is also used as a context menu handler. When you right click drive/folder/file icon in Explorer you can select menu item to defragment the selected object.
To stop the defragmentation press Ctrl+C keys 4 times or close the console application window.
Currently this feature is not available in portable version of the program.
The best practice is to use the console application in batch scripts. You can define all program's options there and defragment multiple volumes in series by typing a single command. Here is the complete example. To try them store the code into ud-example.cmd file and click it's icon.
@echo off
set UD_EX_FILTER=system volume information;temp;recycler
set UD_SIZELIMIT=50Mb
udefrag c: > c:\ud.log
set UD_IN_FILTER=My Documents
udefrag d: >> c:\ud.log
set UD_IN_FILTER=
udefrag e: >> c:\ud.log
The command set UD_IN_FILTER= destroys the specified variable. The appropriate option will have the default value after this command.
The following example demonstrates flexibility of filters which allow you to perform a very effective defragmentation:
@echo off
rem defragment small files
set UD_SIZELIMIT=50Mb
udefrag c:
rem defragment large files
rem which have at least 5 fragments
set UD_SIZELIMIT=
set UD_FRAGMENTS_THRESHOLD=5
udefrag c:
Batch files are powerful enough, try to insert commands to play sounds after each defragmentation. If you doubt that your volumes are in good state then add chkdsk command too. Also you can use shutdown -s -t 00 command to halt your computer after the defragmentation job.
To hibernate your PC use hibernate4win now command. An appropriate tool is included in UltraDefrag package; it installs by default to your system32 directory.