windows 删除文件夹时系统找不到指定的文件错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26923756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:49:01  来源:igfitidea点击:

The System cannot find the file specified error while deleting folder

windowsbatch-filecmd

提问by jestges

Hi can some one suggest me how to delete below folder(abc) using a batch file?

嗨,有人可以建议我如何使用批处理文件删除以下文件夹(abc)?

%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc

I tried like RD %UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc /Q /S

我试过 RD %UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc /Q /S

But it is not deleting and when I execute the same command in command line it is giving a message like "The System cannot find the file specified" even though it is exists.

但它没有删除,当我在命令行中执行相同的命令时,它会给出类似“系统找不到指定的文件”的消息,即使它存在。

Any solution?

有什么解决办法吗?

采纳答案by twasbrillig

At a command line run:

在命令行运行:

ECHO %UserProfile%

What does it return?

它返回什么?

Open that directory in Windows Explorer and double check that a folder called AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abcexists in it.

在 Windows 资源管理器中打开该目录并仔细检查其中是否AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc存在名为的文件夹。

I'm thinking that maybe it doesn't exist, and the folder you're looking at that you said does exist, is in a directory with a root that is different from %UserProfile%.

我在想它可能不存在,并且您正在查看的文件夹确实存在,它位于一个根目录不同于%UserProfile%.

Update

更新

Open a new command window by doing the following, which ensures that it's in Administrator mode.

通过执行以下操作打开一个新的命令窗口,以确保它处于管理员模式。

On a Shortcut to a command window, Right Click > Properties > Shortcut > Advanced and check the "Run As Administrator" checkbox, and click OK twice. Then run the command prompt via the shortcut. You'll know it worked if it looks like this, with the word "Administrator" in the title, see screenshot below. Then try running your RD command again.

在命令窗口的快捷方式上,右键单击 > 属性 > 快捷方式 > 高级并选中“以管理员身份运行”复选框,然后单击确定两次。然后通过快捷方式运行命令提示符。如果它看起来像这样,标题中带有“管理员”一词,您就会知道它有效,请参见下面的屏幕截图。然后再次尝试运行您的 RD 命令。

enter image description here

在此处输入图片说明

回答by techshe

Use 7-zip to "move" them.

使用 7-zip 来“移动”它们。

When facing an inability to delete a file because of "the system cannot find the file specified" I've tried all the common tricks (verify permissions, command line, free unlocker tools, etc). What finally got rid of them for me was 7-zip. Using 9.20 "7-zip File Manager" interface (not just the right click on file options) I was able to "Move" the folder which contained the problem files. Sure, that just moves the problem but there is the beauty, you move them to a disk you can format: a VMDK, a thumb drive, etc... problem solved ;)

当由于“系统找不到指定的文件”而无法删除文件时,我尝试了所有常用技巧(验证权限、命令行、免费解锁工具等)。最终为我摆脱它们的是 7-zip。使用 9.20“7-zip 文件管理器”界面(不仅仅是右键单击文件选项),我能够“移动”包含问题文件的文件夹。当然,这只是解决了问题,但也有好处,您将它们移动到可以格式化的磁盘上:VMDK、拇指驱动器等......问题解决了;)

回答by Hieu Tran AGI

I used "rm -rf PATH_TO_FOLDER" command line on Git Bash (not cmd), then I can delete the similar folder. Note: Tested on Windows 10 (latest version).

我在 Git Bash(不是 cmd)上使用了“rm -rf PATH_TO_FOLDER”命令行,然后我可以删除类似的文件夹。注意:在 Windows 10(最新版本)上测试。

回答by Sibusiso Thabane

Inspired by one of the answers, but instead of using 7-zip I used WinRAR to archive the empty folder. Before archiving the folder there is an option to delete the folder after archiving, select that option and once the folder is a zip file, the folder should be deleted, and you can go ahead and delete the zip file. I am not sure if it will work for you but it worked for me after spending hours on the internet trying to find a solution.

受到其中一个答案的启发,但我没有使用 7-zip,而是使用 WinRAR 来存档空文件夹。在存档文件夹之前,有一个选项可以在存档后删除文件夹,选择该选项,一旦文件夹是 zip 文件,就应该删除该文件夹,您可以继续删除 zip 文件。我不确定它是否对你有用,但在互联网上花了几个小时试图找到解决方案后,它对我有用。

回答by Brian

Here is what worked for me.

这对我有用。

  1. Open command prompt
  2. Browse to parent directory of the folder you want to delete
  3. run 'dir /x' (displays short names - xxxxxx~1)
  4. run 'rd xxxxxx~1' substituting the folder name you want to delete.
  1. 打开命令提示符
  2. 浏览到要删除的文件夹的父目录
  3. 运行 'dir /x'(显示短名称 - xxxxxx~1)
  4. 运行 'rd xxxxxx~1' 替换您要删除的文件夹名称。

I had a problem where two Pictures folders would show under my user profile, and windows wouldn't let me delete the second folder.

我遇到了一个问题,在我的用户配置文件下会显示两个图片文件夹,而 Windows 不允许我删除第二个文件夹。

回答by Ross Ridge

Try putting the directory name in quotes:

尝试将目录名称放在引号中:

rmdir /q /s "%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc"

Otherwise the spaces in the directory name will be interpreted as argument separators.

否则目录名称中的空格将被解释​​为参数分隔符。