Unable to delete or take ownership of folder (Windows 7)
Download PsExec.exe from Sysinternals, this tool allows you to open a command prompt under LOCAL SYSTEM privileges: http://live.sysinternals.com/psexec.exe (put it in C:\temp)
Open a command prompt with Administrator Privileges
CD into C:\temp
Run:
psexec -s -i cmd.exe
, this installs a temporary service which will open a command prompt under LOCAL SYSTEM account. The service will be automatically deleted after you close the screen (i.e. afterEXIT
)Run:
TAKEOWN /F <folder> /R /D Y
, this will set the Administrators group as owner, it also recurses into the folderTo give the Administrators group full control rights, run
ICACLS <folder> /grant administrators:F /T
; the/T
indicates that this operation is performed on all matching files and directories below the directories specified
Related videos on Youtube
fileperms
Updated on September 18, 2022Comments
-
fileperms over 1 year
I have a folder that I am unable to delete.
I also cannot take ownership.
The hard drive is one I have previously used in another PC, if this makes any difference.
When trying to take ownership it says it cannot display the current owner and when trying to take ownership selecting any group says access denied.
I've also tried via the command line using takeown however this too says Access Denied.
Windows 7, and I am logged in as an administrator.
-
Karan about 11 yearsIf you need to delete it and Windows is not allowing you to do so, boot from a Linux Live CD/USB and get rid of the folder.
-
Burhan Khalid over 10 yearsIs it on an external drive? USB or similar?
-
ndemou almost 7 yearsKaran's advice is particularly good for folders with thousands of files because rebooting to Linux is much faster than waiting for take ownership to complete.
-
-
fileperms about 11 yearsThanks, but it still says Access Denied when trying through the cmd prompt opened by psexec
-
Heebr about 11 yearsWhich part says acces denied? TAKEOWN or ICACLS?
-
Heebr about 11 yearsCould be it's locked by some process. Take a look at link if there's something you can use.
-
fileperms about 11 yearstakeown says Access Denied. Additionally the folder is not in use by anything (I had read that question earlier and Unlocker finds nothing).
-
Heebr about 11 yearsIs the folder read-only? Maybe a ATTRIB -R -S -H <folder> will help?
-
Heebr about 11 yearsIf this still doesn't help, try resetting permission (Inherit from above) and give Full rights to everyone by subsequently executing: 1: 'ICACLS <folder> /reset /T', 2: 'ICACLS <folder> /setowner everyone', 3: 'ICACLS <folder> /grant everyone:F'
-
Mahmoud Al-Qudsi over 9 years
takeown
must have parameter/A
specified to assign ownership to the Administrators instead of the local system account. -
Zrin over 7 yearsperform file system check (
chkdsk
on Windows) - perhaps the file system is damaged -
CJBS over 7 years@Zrin - this worked for me (running
chkdsk
). Suggest adding this as an answer. -
David Ferenczy Rogožan about 7 yearsIn my case
takeown
is also saying Access is denied, both with and without the/A
parameter.chkdsk
also didn't help. Does anyone have any other idea, please? I can't believe I'll have a file I can't get rid of my file system :( -
Stephen Drew about 7 yearsHeebr's three-step ICACLS worked in the psexec command line for me.