Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The System cannot find the file specified error while deleting folder

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

%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

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?

like image 750
jestges Avatar asked Nov 14 '14 05:11

jestges


7 Answers

Use 7-zip to "move" them.

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

like image 179
techshe Avatar answered Oct 03 '22 18:10

techshe


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.

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

like image 25
Brian Avatar answered Oct 03 '22 18:10

Brian


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

like image 39
Hieu Tran AGI Avatar answered Oct 03 '22 20:10

Hieu Tran AGI


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.

like image 26
Sibusiso Thabane Avatar answered Oct 03 '22 20:10

Sibusiso Thabane


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.

like image 32
Ross Ridge Avatar answered Oct 03 '22 18:10

Ross Ridge


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\abc exists in it.

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

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.

enter image description here

like image 25
twasbrillig Avatar answered Oct 03 '22 20:10

twasbrillig


The only solution that worked for me was to put \\?\ in front of the path when running rd in command prompt.

For example, to delete D:\bad\folder

Open CMD and then type:

rd /s "\\?\D:\bad\folder"
like image 20
cyberponk Avatar answered Oct 03 '22 20:10

cyberponk