- Messages
- 2,467
- Location
- Bamberg Germany
I've been noticing lately a lot of people have been asking "Why is disk cleanup taking so long???". Some people seen to think Windows just deletes them right away or marks the file for deletion, but there is a little more involved than that, especially for kernel changes such as the updates on Patch Tuesday. Files in use must be flagged, replaced, copied, moved delayed to a temp file, written, and renamed. I'm sure many have seen this term: PendingFileRenameOperations. This must happens to all "in use" files be it drivers, windows defender, and Windows Updates(which should be kept awhile incase of needed rollback or uninstallation) no matter how small or large, it can be a lot and for the cpu(be it a B960 or an i7) it takes time to do.
I finally found a bit of code HERE that shows what happens:
///
/// Consts defined in WINBASE.H
///
internal enum MoveFileFlags
{
MOVEFILE_REPLACE_EXISTING = 1,
MOVEFILE_COPY_ALLOWED = 2,
MOVEFILE_DELAY_UNTIL_REBOOT = 4,
MOVEFILE_WRITE_THROUGH = 8
}
///
/// Marks the file for deletion during next system reboot
///
///
The current name of the file or directory on the local computer.
///
The new name of the file or directory on the local computer.
///
MoveFileFlags
/// bool
/// MoveFileEx function (Windows)
[System.Runtime.InteropServices.DllImportAttribute("kernel32.dll",EntryPoint="MoveFileEx")]
internal static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName,
MoveFileFlags dwFlags);
//Usage for marking the file to delete on reboot
MoveFileEx(fileToDelete, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);The file is marked for deletion in registry in following location
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerPendingFileRenameOperations
I hope this helps and if anyone else can correct or add to this it would be appreciated.
I finally found a bit of code HERE that shows what happens:
///
/// Consts defined in WINBASE.H
///
internal enum MoveFileFlags
{
MOVEFILE_REPLACE_EXISTING = 1,
MOVEFILE_COPY_ALLOWED = 2,
MOVEFILE_DELAY_UNTIL_REBOOT = 4,
MOVEFILE_WRITE_THROUGH = 8
}
///
/// Marks the file for deletion during next system reboot
///
///
The current name of the file or directory on the local computer.
///
The new name of the file or directory on the local computer.
///
MoveFileFlags
/// bool
/// MoveFileEx function (Windows)
[System.Runtime.InteropServices.DllImportAttribute("kernel32.dll",EntryPoint="MoveFileEx")]
internal static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName,
MoveFileFlags dwFlags);
//Usage for marking the file to delete on reboot
MoveFileEx(fileToDelete, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);The file is marked for deletion in registry in following location
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerPendingFileRenameOperations
I hope this helps and if anyone else can correct or add to this it would be appreciated.
My Computer
System One
-
- OS
- Windows 8.1 Update Pro in Hyper-V/Windows 10 Pro 64 bit
- Computer type
- PC/Desktop
- System Manufacturer/Model
- Cliff's Black & Blue Wonder
- CPU
- Intel Core i9-9900K
- Motherboard
- ASUS ROG Maximus X Hero
- Memory
- 32 GB Quad Kit, G.Skill Trident Z RGB Series schwarz, DDR4-3866, 18-19-19-39-2T
- Graphics Card(s)
- ASUS GeForce RTX 3090 ROG Strix O24G, 24576 MB GDDR6X
- Sound Card
- (1) HD Webcam C270 (2) NVIDIA High Definition Audio (3) Realtek High Definition Audio
- Monitor(s) Displays
- BenQ BL2711U(4K) and a hp 27vx(1080p)
- Screen Resolution
- 1920 x 1080 x 32 bits (4294967296 colors) @ 60 Hz
- Hard Drives
- C: Samsung 960 EVO NVMe M.2 SSD
E: & O: Libraries & OneDrive-> Samsung 850 EVO 1TB
D: Hyper-V VM's -> Samsung PM951 Client M.2 512Gb SSD
G: System Images -> HDD Seagate Barracuda 2TB
- PSU
- Corsair HX1000i High Performance ATX Power Supply 80+ Platinum
- Case
- hanteks Enthoo Pro TG
- Cooling
- Thermaltake Floe Riing RGB TT Premium-Edition 360mm and 3 Corsair blue LED fans
- Keyboard
- Trust GTX THURA
- Mouse
- Trust GTX 148
- Internet Speed
- 25+/5+ (+usually faster)
- Browser
- Edge; Chrome; IE11
- Antivirus
- Windows Defender of course & Malwarebytes Anti-Exploit as a
- Other Info
- Router: FRITZ!Box 7590 AX V2
Sound system: SHARP HT-SBW460 Dolby Atmos Soundbar
Webcam: Logitech BRIO ULTRA HD PRO WEBCAM 4K webcam with HDR