删除文件到回收站

1 $testFile="pstips.net"
2 dir | Out-File $testFile
3 $shell = new-object -comobject "Shell.Application"
4 $item = $shell.Namespace(0).ParseName( (Resolve-Path $testFile).Path)
5 $item.InvokeVerb("delete")

注意第4行,一定要用绝对路径,使用相对路径可能会报错

From:http://www.pstips.net/remove-file-to-recycle-bin.html

posted on 2014-08-22 09:53  momingliu11  阅读(270)  评论(0编辑  收藏  举报