It turns out that, even though the code for FileRecycle includes it, the FOF_WANTNUKEWARNING flag
is not doing its job properly.SHFILEOPSTRUCTW structure wrote: FOF_WANTNUKEWARNING
Send a warning if a file is being permanently destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.
I would like to recommend that the FileRecycle command include a check of the NukeOnDelete registry value for the drive associated with the file. If that value is true, FileRecycle should do nothing and set ErrorLevel to 1. Below is a function that performs the check:
Code: Select all
IsNukeOnDelete(FilePattern) {
static TCHAR_Size := A_IsUnicode ? 2 : 1
; Get the drive letter associated with FilePattern
Size := DllCall("Kernel32.dll\GetFullPathName", "Str", FilePattern, "UInt", 0, "Ptr", 0, "PtrP", 0, "UInt")
VarSetCapacity(FullPathName, Size * TCHAR_Size, 0)
DllCall("Kernel32.dll\GetFullPathName", "Str", FilePattern, "UInt", Size, "Str", FullPathName, "PtrP", 0, "UInt")
SplitPath, FullPathName, , , , , Drive
; Get the GUID associated with the drive
VarSetCapacity(VolumeName, 50 * TCHAR_Size, 0)
DllCall("Kernel32.dll\GetVolumeNameForVolumeMountPoint", "Str", Drive "\", "Str", VolumeName, "UInt", 50, "Int")
RegExMatch(VolumeName, "\{.*}", GUID)
; Now that we have the GUID, we can look up the value of NukeOnDelete in the registry
RegRead, NukeOnDelete, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\Volume\%GUID%, NukeOnDelete
Return NukeOnDelete
}
Code: Select all
if !IsNukeOnDelete(FilePattern)
FileRecycle, %FilePattern%