I need a code to empty the recycling bin without conformation I have tried the simple del $Recycle.Bin
but it says access denied even when elevated does any one know a code I could use.
This emptied my bin without any confirmation.
@ECHO OFF
start /b /wait powershell.exe -command "$Shell = New-Object -ComObject Shell.Application;$RecycleBin = $Shell.Namespace(0xA);$RecycleBin.Items() | foreach{Remove-Item $_.Path -Recurse -Confirm:$false}"
Above answers are ok for cmd batch files but for the new powershell there is a better way
Simply use the cmdlet
Clear-RecycleBin
Optionally you can use the -Force or -Confirm:$false parameters so it won't ask for confirmation
For more info open powershell and type
Get-Help Clear-RecycleBin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With