Zend certified PHP/Magento developer

What is the cmd.exe command to determine the last mounted drive letter on Windows 11?

I’m trying to be able to determine on the command line (so that I can do it from my scripting language) the drive letter for the last mounted drive on Windows 11.

Up until recently, I have used the command wmic logicaldisk get name and then extracted the drive letter in the bottom/end of the list. However, I have discovered that this does not necessarily correspond to the last mounted drive!

For months, it seemed like it did, but it does not. At least not on Windows 11. I can’t tell if it was just working out of sheer luck on Windows 10, or if Microsoft actually changed how this command returns data in Windows 11. Either way, it can no longer be relied upon to put the last mounted in the very end/bottom. So I need some other command to do the same.

Important: I have verified that the age-old Windows 10 (and possibly earlier) bug which caused any Powershell command run from cmd.exe to mess up the terminal visually has not been fixed in Windows 11, so I unfortunately cannot use anything that requires calling Powershell. Please do not suggest Powershell commands. I also cannot drop cmd.exe entirely in favour of either Powershell or Windows Terminal due to the extreme slowness and resource (CPU/RAM) usage of these terminals compared to the infinitely faster and leaner cmd.exe. It really does make such a critical difference, at least in all my extensive testing.