Thanks, tbone, "driveType" resolves the problem of USB drives, network drives, and DVD drives very easily, and I should have remembered it because I used it only a few weeks ago.
But it doesn't resolve the problem of drives mounted by VeraCrypt (the standard TrueCrypt replacement). When I mount an encrypted VeraCrypt container as a drive, say as W: drive, then "driveType" reports it as Type 2, that is, as a fixed drive, so that within the script, W: drive is indistinguishable from C: and D: drives.
- This is odd, because Windows does not send files deleted from W: drive to the Recycle Bin, so Windows must know that it is not an ordinary drive.
- Also, W: drive does not show up in "Disk Management" in the Control Panel, so again, Windows knows that W: drive is different from C: drive and D: drive.
It was deletions yesterday of a couple of financial records from this particular W: drive that made me realise how important an Ersatz Recycle Bin is. (I later realised that I didn't actually need those two files.)
I looked a bit at WMI, but it seems exceedingly complicated, and googling produces other people asking the same question. It looks as if the best solution is to teach the script what directories use the recycle bin, on each computer on our network. Then on any other drive, "Delete" can move the file to the "@ForDeletion" directory. Alternatively, because I only mount Veracrypt drives using DOpus buttons, I could easily create a non-persistent DOpus global variable that records the drive letters of all mounted drives.
On a different point, the moved file or directory needs a date–time stamp on the end for when it is deleted, otherwise there are duplication problems with directories — this is because the standard DOpus command "Copy Move WhenExists=Rename" works for files, but for some reason that I don't understand it doesn't work for directories.
No worries, because the "Date Deleted" is an essential feature of the normal Recycle Bin, and adding it to the filename is the best method of recording it. On the other hand, recording the "Original Location" would be more difficult, and would probably have to use Alternate Data Streams.