如何通过命令提示符清空回收站? [英] how to empty recyclebin through command prompt?

查看:151
本文介绍了如何通过命令提示符清空回收站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我们通过鼠标右键单击并选择清空回收站"来删除回收站内容.但是我有一个要求,我需要使用命令提示符删除回收站内容.这可能吗?如果是这样,我该如何实现?

Usually we delete the recycle bin contents by right-clicking it with the mouse and selecting "Empty Recycle Bin". But I have a requirement where I need to delete the recycle bin contents using the command prompt. Is this possible? If so, how can I achieve it?

推荐答案

通过永久删除驱动器上包含系统文件的回收站目录,您可以从命令行有效地清空"回收站.(在大多数情况下,这将是 C: 驱动器,但您不应该对该值进行硬编码,因为它并不总是正确的.相反,请使用 %systemdrive% 环境变量.)

You can effectively "empty" the Recycle Bin from the command line by permanently deleting the Recycle Bin directory on the drive that contains the system files. (In most cases, this will be the C: drive, but you shouldn't hardcode that value because it won't always be true. Instead, use the %systemdrive% environment variable.)

这种策略有效的原因是因为每个驱动器都有一个名为 $Recycle.bin 的隐藏的受保护文件夹,这是回收站实际存储已删除文件和文件夹的地方.删除此目录后,Windows 会自动创建一个新目录.

The reason that this tactic works is because each drive has a hidden, protected folder with the name $Recycle.bin, which is where the Recycle Bin actually stores the deleted files and folders. When this directory is deleted, Windows automatically creates a new directory.

因此,要删除目录,请使用带有 /s 的 rd 命令 (r emove d ictory) 参数,它表示指定目录中的所有文件和目录也应该被删除:

So, to remove the directory, use the rd command (r​emove d​irectory) with the /s parameter, which indicates that all of the files and directories within the specified directory should be removed as well:

rd /s %systemdrive%$Recycle.bin

请注意,此操作将永久从所有用户帐户中删除当前在回收站中的所有文件和文件夹.此外,您将(显然)必须从提升的命令提示符运行该命令,以便有足够的权限来执行此操作.

Do note that this action will permanently delete all files and folders currently in the Recycle Bin from all user accounts. Additionally, you will (obviously) have to run the command from an elevated command prompt in order to have sufficient privileges to perform this action.

这篇关于如何通过命令提示符清空回收站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆