Skip to main content

OODCMD examples and scripting

Run these examples only for the drives you intend to maintain. Replace drive letters and the installation path when necessary.

Inspect before changing a drive

OODCMD list
OODCMD status C:
OODCMD analyze C:

The first two commands report state. The last analyzes the layout without reorganizing files.

Run a chosen method and wait

OODCMD defrag C: --method solid-quick
OODCMD solid D: E: --verbose

The first command uses the quick SOLID method. The second starts SOLID/Complete on both drives and includes more detail. Multiple drives are processed at the same time; consider whether they share physical storage.

Start and follow separately

OODCMD stealth D: --no-wait
OODCMD status D: --follow --interval 5

The first command returns after acceptance. The second observes the running action. Check the final result rather than treating the first exit code as proof of successful completion.

Stop selected work

OODCMD status D:
OODCMD stop D:
OODCMD status D:

Use stop all only when you intend to stop actions on every drive. Pause and resume both toggle state; always inspect current state first.

PowerShell: analyze and preserve the result

$oodcmd = Join-Path $env:ProgramFiles 'OO Software\Defrag\OODCMD.exe'
if (-not (Test-Path -LiteralPath $oodcmd)) {
throw 'Locate OODCMD.exe in your O&O Defrag installation and update the path.'
}

& $oodcmd analyze C: --quiet
$result = $LASTEXITCODE
if ($result -ne 0) {
Write-Error "O&O Defrag analysis failed with exit code $result."
}
exit $result

Save this as a script if you need its final exit to return a status to a scheduler. When experimenting interactively, omit the final exit so the shell stays open.

To optimize after validating your workflow, replace analyze with the intended named method. Keep waiting enabled if the calling scheduler needs the completion result.

Batch file

This assumes OODCMD is available on PATH or the batch file runs from the installation directory:

@echo off
OODCMD analyze C: --quiet
set "result=%ERRORLEVEL%"
if not "%result%"=="0" echo O^&O Defrag returned exit code %result%.
exit /b %result%

Use a quoted full executable path if it is not on PATH. In a scheduled task, configure the execution account and working directory deliberately. Read the exit-code table when deciding whether to retry: an invalid license or unknown drive requires correction, not repeated attempts.