A bit late and also for the wrong OS, but on Windows 10 Build 21H2 (Windows 7 not tested, other versions of Windows 10 may have different syntax), you could check, if a volume on a single disk supports trim, by starting a manual trim and look for the result.
In an administrative command prompt enter (please vary drive letter):
defrag c: /retrim
Performing this for volume on a HW RAID (a single disk from the point of view of Windows which definitively does not support TRIM without special drivers), it gives me
Microsoft Drive Optimizer
Copyright (c) Microsoft Corp.
Invoking retrim on (E:)...
Retrim: 100% complete.
The operation requested is not supported by the hardware backing the volume. (0x8900002A)
whereas on my system disk it gives me
Microsoft Drive Optimizer
Copyright (c) Microsoft Corp.
Invoking retrim on (C:)...
The operation completed successfully.
Post Defragmentation Report:
Volume Information:
Volume size = 465.15 GB
Free space = 422.79 GB
Retrim:
Total space trimmed = 422.58 GB
Unfortunately, this command does not set the errorlevel, so if you want to process the result programmatically, you must parse the output and this is language dependent.
BTW: This command can be executed if DisableDeleteNotify
is enabled or not.
But wait... This would be too easy. I have a Striped Volume (software RAID in Windows consisting of several disks), and have DisableDeleteNotify
set to 0
(i.e. TRIM is generally enabled), the command above gives me the result "not supported by the hardware". But I have seen effects that the disks in the volume are busy for several minutes writing to $Log
and $Mft
. After setting DisableDeleteNotify
to 1
, these effects were gone. So I think these disks were trimmed, no matter what that command above said.