0
I use this to clear the recycle bin of Windows:
powershell -command "& {Clear-RecycleBin -force}"
or even simpler
powershell Clear-RecycleBin -force
The command appears to work, but there's an error shown ("the system cannot find the file specified")
Clear-RecycleBin : Das System kann die angegebene Datei nicht finden
In Zeile:1 Zeichen:1
+ Clear-RecycleBin -force
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (RecycleBin:String) [Clear-RecycleBin], Win32Exception
+ FullyQualifiedErrorId : FailedToClearRecycleBin,Microsoft.PowerShell.Commands.ClearRecycleBinCommand
As it seems, I could prevent the error with the additional parameter "-ErrorAction:Ignore". But I'd like to know what's wrong or why the error occurs in the first place. Any idea?
You need to translate the error for us – Ramhound – 2017-12-10T13:38:20.220
Sure - it's "file not found", or more detailed "the system cannot find the file specified" in "line:1, char:1". – JeffRSon – 2017-12-10T13:48:52.317
Whats wrong with just using 'Clear-RecycleBin' or 'Clear-RecycleBin -Force' where are you running the command from? – Antony – 2017-12-14T17:24:08.313
@Antony: It's meant to be a custom command from inside a file manager (TC). But it behaves the same when called from cmd.exe. – JeffRSon – 2017-12-14T20:53:58.247
Duh! I know what it is. Your question just doesn't say from cmd but does say powershell so why not call it in powershell. – Antony – 2017-12-14T22:32:47.533