Windows 10 Files are Locked Can’t Delete Use TakeOwn EXE to Delete the Files

Windows 10 Files are Locked Can’t Delete Use TakeOwn EXE and Delete the Files. The good news is that TakeOwn.exe works with Windows 10 versions. TakeOwn.exe is the command-line tool that can be used to take ownership of files and folders.

This tool works well with PowerShell as well as command prompts. Now, you may think, why Powershell? As part of the PowerShell learning process, I’ve removed command prompt shortcuts from Windows 10 laptops. So by default, for everything, I use PowerShell rather than the command prompt.

Windows 10 Files are Locked Can’t Delete Use TakeOwn.EXE to Delete the Files

Windows 10 Files are Locked Can't Delete Use TakeOwn.EXE to Delete the Files
Windows 10 Files are Locked Can’t Delete Use TakeOwn.EXE to Delete the Files

Try checking Windows 10 Files are Locked Can’t Delete Use TakeOwn.EXE to Delete the Files?

Patch My PC
Windows 10 Files are Locked Can't Delete Use TakeOwn.EXE to Delete the Files
Windows 10 Files are Locked Can’t Delete Use TakeOwn.EXE to Delete the Files

Following are the takeown.exe commands I tried from Powershell and the command prompt.

PowerShell = PS C:\> takeown /f .\Windows.old /r /d y

Command prompt = C:\>takeown /f C:\Windows.old /r /d y

/R Recurse: instructs the tool to operate on files in specified directory and all subdirectories.

/F filename Specifies the filename or directory name pattern. Wildcard “*” can be used to specify the pattern. Allows sharename\filename.

/D prompt Default answer is used when the current user does not have the “list folder” permission
on a directory. This occurs while operating recursively (/R) on sub-directories. Valid
values “Y” to take ownership or “N” to skip.

Windows 10 Files are Locked Can’t Delete Use TakeOwn.EXE to Delete the Files

Take Ownership utility results are something similar to the below screenshot. This TakeOwn utility can be used when you cannot delete any of the files and folders, even if you’ve full admin access on your Windows Machine. The random files getting locked and can’t be deleted a very common problem in Windows.

In case, TakeOwn.exe doesn’t work for you; I would suggest trying PSEXEC with system account/machine account privileges to delete a file or folder from Windows 10 machine. I’ve explained this process here “How to Run Application or Process from SYSTEM Context or Account“.

SUCCESS: The file (or folder): "C:\Windows.old\WINDOWS\winsxs\x86_wwf-system.workflow.activities_31bf3856ad364e35_6.1.7601.17514_none_346d5ccdd640c664\System.Workflow.Activities.d
ll" now owned by user "ACN\Anoop".
SUCCESS: The file (or folder): "C:\Windows.old\WINDOWS\winsxs\x86_wwf-system.workflow.componentmodel_31bf3856ad364e35_6.1.7601.17514_none_8deb83646c57c1d5\System.Workflow.Componen
tModel.dll" now owned by user "ACN\Anoop".

SUCCESS: The file (or folder): “C:\Windows.old\WINDOWS\winsxs\x86_wwf-system.workflow.runtime_31bf3856ad364e35_6.1.7601.17514_none_67224784fe4912e9\System.Workflow.Runtime.dll” no w owned by user “ACN\Anoop”.

Windows 10 Files are Locked Can't Delete Use TakeOwn.EXE to Delete the Files
Windows 10 Files are Locked Can’t Delete Use TakeOwn.EXE to Delete the Files

More help on taking the Ownership tool!

Takeown C:/Windows.old\*

PS C:\WINDOWS\system32> Takeown /?

TAKEOWN [/S system [/U username [/P [password]]]]
/F filename [/A] [/R [/D prompt]]

Description:

  • This tool allows an administrator to recover access to a file denied by re-assigning file ownership.

Parameter List:

  • /S system Specifies the remote system to connect to.
  • /U [domain\]user Specifies the user context under which the command should execute.
  • /P [password] Specifies the password for the given user context. Prompts for input if omitted.
  • /F filename Specifies the filename or directory name pattern. Wildcard “*” can be used to specify the pattern. Allows sharename\filename.
  • /A Gives ownership to the administrators group instead of the current user.
  • /R Recurse: instructs the tool to operate on files in specified directory and all subdirectories.
  • /D prompt Default answer is used when the current user does not have the “list folder” permission
    on a directory. This occurs while operating recursively (/R) on sub-directories. Valid
    values “Y” to take ownership or “N” to skip.
  • /SKIPSL Do not follow symbolic links. Only applicable with /R.
  • /? Displays this help message.

NOTE

  • 1) If /A is not specified, file ownership will be given to the
    currently logged-on user.
  • 2) Mixed patterns using “?” and “*” are not supported.
  • 3) /D is used to suppress the confirmation prompt.

Examples:

TAKEOWN /?
TAKEOWN /F lostfile
TAKEOWN /F \\system\share\lostfile /A
TAKEOWN /F directory /R /D N
TAKEOWN /F directory /R /A
TAKEOWN /F *
TAKEOWN /F C:\Windows\System32\acme.exe
TAKEOWN /F %windir%\*.txt


TAKEOWN /S system /F MyShare\Acme*.doc
TAKEOWN /S system /U user /F MyShare\MyBinary.dll
TAKEOWN /S system /U domain\user /P password /F share\filename
TAKEOWN /S system /U user /P password /F Doc\Report.doc /A
TAKEOWN /S system /U user /P password /F Myshare\*
TAKEOWN /S system /U user /P password /F Home\Logon /R
TAKEOWN /S system /U user /P password /F Myshare\directory /R /A

Resources

Windows 10 Latest Version Of Client Operating System From Microsoft (anoopcnair.com)

Author

Anoop is Microsoft MVP! He is a Solution Architect in enterprise client management with more than 20 years of experience (calculation done in 2021) in IT. He is a logger, Speaker, and Local User Group HTMD Community leader. His main focus is on Device Management technologies like SCCM 2012, Current Branch, and Intune. He writes about ConfigMgr, Windows 11, Windows 10, Azure AD, Microsoft Intune, Windows 365, AVD, etc…

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.