Recently, I happened to discover a safe way to do this in any language, though I’ve only tested it on Windows 11 25H2.
1 | ChkDsk.exe [Drive] /F /R