[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

Delete Files and Folders from Storage Server ('Permission or Access Denied')

A site is trying to delete a 200 GB folder (and associated files) from a network storage server, but when trying to delete many or most of the files and folders say 'Access Denied' or 'Administrator Permissions Needed' when trying to delete.  After signing on to the machine with a local and domain Admin account and attempting to take ownership of the folder and files the same message appears - and the Take Ownership process fails.  Apparently some or many of the files and folders are .NET developer-created files or copied system files.  How can one quickly and easily delete that entire folder (in one step) without having to drill down into each subfolder, reset the file and folder permissions, manually take ownership of the smaller subfolders one by one, delete, and then repeat (which seems to work but is very time consuming as there are hundreds of folders) ??  For some reason it will work at the drilled-down subfolder level but fails when attempting to do at the top folder level.  TIA ...
0
LGroup1
Asked:
LGroup1
3 Solutions
 
Jian An LimCommented:
will
DOS
rmdir <directory> /s /q



works?
0
 
CoralonCommented:
Takeown.exe is your friend.  This command gives admins ownership of the files & directories recursively, and answers any prompts with a yes.  

takeown /a /f <file|directory> /r /d y /skipsl

Then you can cacls.exe against that same directory.. I just answered another article along the same lines

So, to convert it to a batch file (assuming a root/parent directory)

pushd \\server\share\<parent>
for /d %f in (*) do takeown /a /f "%f" /r /d y /skipsl
for /d %f in (*) do cacls "%f" /e /t /g administrators:f
for /d %f in (*) do attrib -s -h -r "%f" /s /d /l
for /d %f in (*) do rd /s/q "%f"
popd

Open in new window


That should cover most circumstances.  (This is assuming you are starting with directories..)

Coralon
0
 
Lionel MMSmall Business IT ConsultantCommented:
Once you have ownership here is also another quick and easy trick--use robocopy. Create a folder, let say Del1 with nothing in it then use robocopy to mirror Del1 to the location you want to delete like this
robocopy c:\del1 \\servername\sharename /mir /s
This will get rid of everything, quick and easy.
0
 
CoralonCommented:
I hadn't thought of that Lionelmm.. that's a great tip...

Coralon
0
 
LGroup1Author Commented:
Great answers - thanks all !
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now