0

According this answer in How do I delete a folder which is nested quite deep and avoid “File name too long”?, I created 1.bat file with following source:

@echo off
if not (%1)==() cd %1
for /D %%i in (*) do if not %%i==_ ren "%%i" _
pushd _ 
%0 
popd

I put this file near the folder which I want to delete.

enter image description here

I click on 1.bat

and see following:

.....
Access is denied.
The system cannot find the path specified.
Access is denied.
The system cannot find the path specified.
Access is denied.
The system cannot find the path specified.
Access is denied.
The system cannot find the path specified.
Access is denied.
The system cannot find the path specified.
Access is denied.
....

What do I wrong?

gstackoverflow
  • 259
  • 5
  • 14
  • Are you running the script as Administrator? Have you checked whether you have ownership of the folder and all its sub-folders? – Vinayak Oct 03 '14 at 07:57
  • Now I repeated all steps one more time and I see following result **Access is denied. '1.bat' is not recognized as an internal or external command, operable program or batch file.** – gstackoverflow Oct 03 '14 at 08:04
  • Yes I tryed to execute as admin – gstackoverflow Oct 03 '14 at 08:04
  • You mustn't execute the script as administrator as the default script path becomes `C:\Windows\System32` when running it as administrator. – Vinayak Oct 03 '14 at 08:07
  • You should try [taking ownership of the folder and all its sub-folders](http://technet.microsoft.com/en-us/magazine/ff404240.aspx) before running the script. – Vinayak Oct 03 '14 at 08:09
  • http://cdn.joxi.ru/uploads/prod/2014/10/03/7b8/7fd/f6bc90bb09aef943a63831b9aaf4838ebac62b98.jpg – gstackoverflow Oct 03 '14 at 08:26
  • And are you listed as the current owner of the folder as well as its subfolders? – Vinayak Oct 03 '14 at 08:32
  • I clicked as on picture for root folder – gstackoverflow Oct 03 '14 at 08:37
  • Yeah, I figured as much. But are you listed as the current owner of the folder? And do you see `Full Control` in the `Access` column for the Principal you're a member of (e.g. `COMPUTERNAME\Administrators`) – Vinayak Oct 03 '14 at 08:56
  • I think yes http://joxi.ru/zWUuVIwyTJDPAgT-K_k – gstackoverflow Oct 03 '14 at 09:01
  • The screenshot shows that `Authenticated Users` have `Full Control` privileges. It doesn't show the privileges for the `Administrators` group. However, assuming you got it right, try running the script again (not as Administrator). If you still see the "Access is denied" error, it could mean you haven't yet properly taken ownership. Alternatively, try running the command prompt as Administrator and follow this guide to [take ownership of folders recursively](http://www.nextofwindows.com/how-to-silently-recursively-take-ownership-of-a-folder-and-sub-folders-in-command-prompt/). – Vinayak Oct 03 '14 at 09:11

0 Answers0