ArchLinux
ArchLinux

Reputation: 13

Batch Script which deletes all files out of the Recycle Bin

I tried this but it says "no permission"

@echo off 
echo %~dp0
rd /s c:\$Recycle.Bin
pause

I need help. Please

Upvotes: 1

Views: 1813

Answers (3)

ArchLinux
ArchLinux

Reputation: 13

Thank You This was helpfull :))

Upvotes: 0

Dominique
Dominique

Reputation: 17501

I'm not sure if this is possible as a regular user:

Googling "empty recycle bin commandline" led me to this URL, advising following command:

cleanmgr /sageset:1

This will indeed empty the recycle bin, but the tool seems to be interactive. I asked help via following command:

cleanmgr /?

But this gave me no clue on how to do this without user interaction.

Upvotes: 1

Alice Huston
Alice Huston

Reputation: 26

Having just run the script myself, it looks like it does succeed in deleting the contents of the Recycling Bin. I also got the same permissions error you did.

However, I ran it again later as administrator and not only was the Recycling Bin deleted but it also did not give the permissions error. So its just a permissions bug and otherwise everything should behave as expected! You can probably run this without elevated permissions and be just fine, if you don't mind seeing the permission denied message. Probably better safe than sorry here.

Note: I daily drive Linux and am by no means an expert with Windows. I am not sure how dangerous the script is, but be careful with it regardless since it can delete files with elevated permissions (if you wanted to get rid of the permission denied messages).

Upvotes: 0

Related Questions