Empty recycle bin

Please use below script to clear Recycle bin ,

Note: This will clear recycle bin for all users.

import os;
import ctypes

class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
    def __enter__(self):
        self.old_value = ctypes.c_long()
        self.success = self._disable(ctypes.byref(self.old_value))
    def __exit__(self, type, value, traceback):
        if self.success:

with disable_file_system_redirection():
    clear=os.popen('rd /s /q %systemdrive%\$Recycle.bin').read();

Sample output would be,


I just ran this on Win 7 enterprise desktop and it doesn’t work. The status shows as Finished success on the Procedure Log status.

Hi @ikondata

Do you mean the recycle bin is still not empty on the endpoint?

Did you run as a system user or logged in user?


Tried both user types and did not work.

Hi @ikondata

Your request to resolve script issue is in progress. I will let you with updated procedure.

Hi @ikondata

I have tested the script and i am unable to reproduce the issue. It works with our Windows Enterprise x64 bit.

I request you to test below script,


If problem continues , please let me know. We can schedule Teamviewer session and troubleshoot .