'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?
Solution 1:[1]
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.
Solution 2:[2]
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 ;)
Solution 3:[3]
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).
Solution 4:[4]
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.
Solution 5:[5]
Here is what worked for me.
- Open command prompt
- Browse to parent directory of the folder you want to delete
- run 'dir /x' (displays short names - xxxxxx~1)
- 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.
Solution 6:[6]
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.
Solution 7:[7]
The only solution that worked for me was to put \?\ in front of the path.
For example, to delete D:\bad\folder
Open CMD and then type:
rd /s "\\?\D:\bad\folder"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | techshe |
Solution 3 | Hieu Tran AGI |
Solution 4 | Sibusiso Thabane |
Solution 5 | Brian |
Solution 6 | Ross Ridge |
Solution 7 | cyberponk |