
FFB V2.0 - Freeware by Uwe Sieber - www.uwe-sieber.de

FFB - Flush File Buffers is a commandline tool which flushes
the write cache of one or more storage volumes. It is similar
to the Unix sync command or the Sysinternals sync tool.

The name comes from the Win32 API call FlushFileBuffers:
https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-flushfilebuffers


The Sysinternals sync tool can flush volumes only which have
a drive letter. And it forgets drive Z: when called without
parameters.

Since V0.9 FFB skips the flushing of sleeping drives unless -f (force) is given.
VHD, TrueCrpyt and VeraCrypt volumes are resolved to their physical
drives, other file-hosted drives are not, so unwanted wakeups might happen.

Since V1.0 it can purge a volume's the file cache, discarding even the read cache.
This is done by attempting to open the volume for exclusive read access.
Even if this fails with ERROR_SHARING_VIOLATION it purges the cache.

Since V2.0 it can purge a file's file cache, discarding even the read cache.
This is done by opening it exclusively with FILE_FLAG_NO_BUFFERING. This
succeeds only if the file isn't opened anywhere.
This has no effect on files that are NTFS compressed since Windows must
ignore FILE_FLAG_NO_BUFFERING here! 

Both tricks are undocumented behavior but tested from Windows 2000 up to Windows 11 24H2.



Usage for volumes:

FFB [VolumeSpec1] [VolumeSpec2] ... [VolumeSpecN] [-d] [-f] [-p] [-n]

VolumeSpec can be a drive letter, a drive or any kind of mountpoint
-p  purge the file cache
-d  dismount the volume(s) if possible
-f  force dismount (open handles become invalid) or force flush of sleeping drives
-n  no wait for key on finish if started standalone


Usage for files:

FFB [FileSpec1] [FileSpec2] ... [FileSpecN] [-n]

FileSpec must be a file specification, either absolute or relative. Wildcards are not supported.
-n  no wait for key on finish if started standalone


Volumes and files cannot be mixed.


Samples:

FFB C
FFB C D E
FFB C: D: E:
FFB C:\ D:\ E:\
FFB C:\CardReader\SD
FFB \\?\Volume{16b5dd59-158f-11e1-b349-00166f0dc865}
FFB \\?\Volume{16b5dd59-158f-11e1-b349-00166f0dc865}\
FFB X: -d -f

FFB C:\Temp\Archive.zip


Flushing and purging a volume's cache requires admin privileges, so,
restricted users cannot do that.

My Windows service "USB Drive Letter Manager (USBDLM)" since V4.8
has a command interface which FFB can use for flushing a volume's
file cache. Purging needs USBDLM V5.3.
See USBDLM help in section "Settings" for details.
http://www.uwe-sieber.de/usbdlm_e.html


Uwe Sieber
March 2025





