Empty Recyle Bin via script in Ignition


Is there way to programmatically empty recycle bin on the computer that runs Ignition client?

This method doesn’t work:

import winshell
winshell.recycle_bin().empty(confirm=False, show_progress=False, sound=False)

There is no winshell module within Ignition.

Wondering if there is other way to do it?

Thank you,

Modern Windows will give you a UAC prompt before successfully removing anything from the recycle bin, so I doubt this will work, but you could try system.util.execute combined with one of the methods from this post: https://www.windows-commandline.com/empty-recycle-bin-command-line/

Yeah, those methods don’t work thru system.util.execute. Thanks for looking into this Paul @PGriffith.

I may just configure recycle bin to not accept anything, should work for the application.

I like this one, personally.

1 Like

You’ll need to execute it via CMD:
system.util.execute(["cmd", "/c rmdir /q /s %systemdrive%\$Recycle.bin"])

1 Like