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

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

问题描述

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

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.)

这个策略的原因是每个驱动器都有一个隐藏的name $ 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.

因此,要删除目录,请使用 rd 命令( r emove d 目录)与 / s 参数,并且应该删除指定目录中的目录:

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.

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

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