1

I was trying to clean up the SoftwareDistribution folder on a virtualized server after some botched updates. Long story short - I now have a folder which seems to be empty but which I can't remove. Note: this is all on a virtualized VHDX drive. The same issues occur from inside the virtualized OS as well as from the host OS if the VHDX is attached there (after the virtualized OS is shut down of course).

I'm the owner of the folder and all contents according to the security settings. There are no hidden nor system files inside. If I attempt to delete the folder using Shift+Delete and confirm the prompt then nothing happens. If I just press Delete on the folder I get Error 0x80070091: The directory is not empty.

I've also checked the disk for errors and came up empty.

I'm not sure how to proceed; I've had run-ins with corrupted files and folders in the past and my slew of usual solutions failed here; it's not a strange character as far as I can tell, it's not physical corruption, it's not a permissions issue. What else can I try?

MBender
  • 383
  • 2
  • 5
  • 23
  • The folder is probably locked by the various Windows Update and Background Intelligent Transfer Services (BITS) because that's where they will want to download things. You may have to completely shutdown Windows Update and some other things to release it. Otherwise we have various questions about similar problems such as [Find out which process is locking a file or folder in Windows](https://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows) and https://superuser.com/questions/72280/cant-delete-folder-in-windows-7?rq=1 – Mokubai Mar 12 '22 at 12:53
  • Restart it run Disk Cleanup. Select "cleanup system files" and after the first pass of disk cleanup, select all items for cleanup and say OK. – John Mar 12 '22 at 13:36
  • @Mokubai That WOULD be a good guess.. except the same thing happens when the VHDX is attached to the host OS (with the virtualized OS being disabled). At this point it's just an external drive and should have no services running on it. Additionally Windows returns a different error when files / folders are in use. – MBender Mar 12 '22 at 14:10
  • @John Does "Disk Cleanup" search the WHOLE disk or just pre-defined locations? Because I've since renamed and moved the troublesome folders (since my original goal was to install patches via Windows Update and I had to clean up the SoftwareDistribution folder). – MBender Mar 12 '22 at 14:14
  • It cleans up the folders you check off in Disk Cleanup. If you moved folders that may affect what Disk Cleanup removes. It cleans up Software Distribution. – John Mar 12 '22 at 14:23

2 Answers2

0

I've managed to fix the issue. Apparently VHDX volumes can become corrupted as well.

Solution was to:

  • attach VHDX to a host OS (after shutting down the OS residing on the VHDX)
  • run CHKDSK X: /scan /f where X is the volume letter after attaching

Disk check fixed whatever issues there were with the VHDX and afterwards I was able to delete the folder normally and without any other problems.

MBender
  • 383
  • 2
  • 5
  • 23
-1

You can’t delete that folder without stopping the Windows Update and Background Intelligence Transfer Service services, and possibly the Windows Modules Installer service.

Appleoddity
  • 11,565
  • 2
  • 24
  • 40
  • You didn't read the question; I've attached the VHDX in question to the host OS while the virtualized OS was turned off. Obviously no services were running at that point, yet I was unable to delete the folder. – MBender Mar 12 '22 at 20:31