Command prompt: Empty recycle bin

1131850 pts.
Tags:
command prompt
Recycle Bin
I've been doing some work inside the command prompt and I was wondering if I could empty the recycle bin using it. Is that possible?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Found this helpful info on another site

You can effectively “empty” the Recycle Bin from the command line by
permanently deleting the Recycle Bin directory on the drive that
contains the system files. (In most cases, this will be the C: drive, but you shouldn’t hardcode that value because it won’t always be true. Instead, use the %systemdrive% environment variable.)

The reason that this tactic works is because each drive has a hidden, protected folder with the name $Recycle.bin,
which is where the Recycle Bin actually stores the deleted files and
folders. When this directory is deleted, Windows automatically creates a
new directory.

So, to remove the directory, use the rd command (r​emove d​irectory) with the /s parameter, which indicates that all of the files and directories within the specified directory should be removed as well:

rd /s %systemdrive%\$Recycle.bin

Do note that this action will permanently delete all files and folders currently in the Recycle Bin from all user accounts.
Additionally, you will (obviously) have to run the command from an
elevated command prompt in order to have sufficient privileges to
perform this action.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Jaideep Khanduja
    Yes, you can by changing directory to relevant folder and then deleting files. But I wonder why you want back the cui environment back from the user friendly gui environment.
    18,930 pointsBadges:
    report
  • TheRealRaven
    The 'Answer' above is partly correct, though it's a direct, unattributed copy of a StackOverflow answer from five years ago. (It even includes line endings, bolded text and other attributes.)

    Does ITKE allow this?

    Anyway, what OS are you using? Different OSs (and different versions of Windows) will have different answers.
    33,610 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: