To Force Delete A Folder/File

1 minute read

Description:

I don’t know why this keeps coming up, but I have the hardest time deleting files/folders sometimes despite using Unlocker and FileAssasin. Follow these steps to work on issues like these.

To Resolve:

  1. First navigate to the directory in Windows Explorer. Hold down CTRL + Right click => Open Command Window here. You may have to close that CMD prompt and open CMD as administrator.

  2. Type:

    1
    2
    3
    4
    5
    6
    7
    8
    
    rmdir (foldername) /s 
    # Gives error
    
    del *.* 
    # Gives error
    
    takeown /f (foldername) /r /d y 
    # Gives error
    
  3. Since those don’t work, lets try doing it running as NTAUTHORITY\SYSTEM: type

    1
    2
    3
    4
    5
    6
    
    # NOTE: This assumes you have PSTools installed and added to your PATH variable.
    psexec -sid cmd.exe
    
    whoami 
    # Should return system
    # Try step 2 again, still no go
    
    • You used to be able to run:
    1
    2
    3
    
    at 11:10 /interactive cmd.exe
    # Where 11:10 is the current time (HH:MM 24 hour) plus 1 minute.
    # The /interactive switch has been depreciated though.
    
  4. Right click each file with the Unlocker windows explorer extension => Delete on next reboot. This works!

  5. If you have a path too long error, just type:

    1
    2
    
    robocopy c:\empty C:\deleteme /purge
    # NOTE: This will delete that folder (c:\deleteme) and all subfolders for you!
    

Comments