如何在Windows批处理脚本或Perl中将文件移动到回收站?

l0b*_*0b0 6 windows perl batch-file

我有一个Windows XP批处理脚本清理一些目录,但我想将删除的文件移动到垃圾桶而不是使用普通del.这是怎么做到的?

看起来我可以使用的唯一语言是普通批处理或Perl.

FMc*_*FMc 7

use Win32::FileOp qw(Recycle);
Recycle(@ARGV);
Run Code Online (Sandbox Code Playgroud)


Sha*_*men 5

编写一个VBS脚本(原始链接)然后用MyDelScript.vbs调用它

function main()
{
  if (WScript.Arguments.length != 1)
  {
    WScript.Echo("<Insert informative error message here>");
    return;
  }

  var Path = WScript.Arguments(0);
  var Shell = WScript.CreateObject("Shell.Application");
  var Item = Shell.Namespace(0).ParseName(Path);
  Item.InvokeVerb("delete");
}
Run Code Online (Sandbox Code Playgroud)