How to move files to RECYCLE.BIN in powershell WITHOUT interactive dialog in case when the file is busy or any other error? I tried to use
Add-Type -AssemblyName Microsoft.VisualBasic
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($f.FullName,'OnlyErrorDialogs','SendToRecycleBin')
This will suspend execution and show me an error dialog.
Same is with using COM:
function safeRemove($fileFullName)
{
$Error.Clear()
$shell = new-object -comobject "Shell.Application"
$path = $fileFullname
$item = $shell.Namespace(0).ParseName("$path")
$item.InvokeVerb("delete")
}
Both methods are unacceptable if it shoud run in a batch job. And of course I'm using $ErrorActionPreference="SilentlyContinue"
Anybody can help?