{"id":264,"date":"2008-05-03T01:31:36","date_gmt":"2008-05-02T20:01:36","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=264"},"modified":"2025-01-26T13:57:26","modified_gmt":"2025-01-26T08:27:26","slug":"take-ownership-of-file-or-folder","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/take-ownership-of-file-or-folder\/","title":{"rendered":"Change Ownership of a File or Folder Using Takeown Command-Line Tool"},"content":{"rendered":"<p>Every file or folder in an NTFS volume has an owner. Certain system files are owned by TrustedInstaller, some by SYSTEM account, and others by the &#8220;Administrators&#8221; group. If a user creates a file or folder, that user is usually the owner of the file or folder. The owner is the one who can assign permissions (Allow or Deny) to other users for that object.<!--more--><\/p>\n<p>If a user is not the owner of a file or folder or has no permissions to access the file, he gets the &#8220;access is denied&#8221; error when accessing the object. If that user is an administrator, he can take ownership of the object using the file or folder&#8217;s Properties &#8211; Security tab. Then he can assign himself the required permissions.<\/p>\n<p>This post tells you how to <strong>take ownership of a file or folder<\/strong>, and assign required permissions for it using the command-line instead of GUI.<\/p>\n<div id=\"toc\">\n<h4>Contents<\/h4>\n<ul>\n<li><a href=\"#takeown_file\">Taking ownership of a file using takeown.exe<\/a><\/li>\n<li><a href=\"#file_permissions\">Assign file permissions using icacls.exe<\/a><\/li>\n<li><a href=\"#takeown_folder\">Taking ownership of a folder using takeown.exe<\/a><\/li>\n<li><a href=\"#folder_permissions\">Assign folder permissions using icacls.exe<\/a><\/li>\n<li><a href=\"#tweaks\">Take Ownership &amp; Assign Permissions via Right-click Menu [Script\/Tweak]<\/a><\/li>\n<\/ul>\n<h4>Additional Info<\/h4>\n<ul>\n<li><a href=\"#icacls_setowner\">INFO: icacls.exe can also change ownership<\/a><\/li>\n<li><a href=\"#trustedinstaller\">Revert the Ownership to TrustedInstaller<\/a><\/li>\n<li><a href=\"#icacls_acc_denied\">ERROR: icacls.exe \/setowner &#8220;Access is Denied&#8221;<\/a><\/li>\n<li><a href=\"#setacl_owner_permissions\">Using SetACL.exe to take ownership and assign permissions <\/a><a href=\"#setacl_owner_permissions\">[3rd Party freeware]<\/a><\/li>\n<\/ul>\n<\/div>\n<p>Windows includes a command-line tool named <b>Takeown.exe,<\/b> which can be used from an <a href=\"https:\/\/www.winhelponline.com\/blog\/open-elevated-command-prompt-windows\/\">admin Command Prompt<\/a> to quickly change the ownership of a file or folder. Here is how to <strong>take ownership of a file or folder<\/strong> and then assign permissions for an account using the command-line.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3282\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/05\/takeown-cmd.png\" alt=\"Take Ownership using command-line takeown.exe\" width=\"600\" height=\"300\" \/><\/p>\n<h3><a id=\"takeown_file\"><\/a>Taking ownership of a file<\/h3>\n<p>Open an <a href=\"https:\/\/www.winhelponline.com\/blog\/open-elevated-command-prompt-windows\/\">elevated Command Prompt<\/a> window. Use the following syntax to take ownership of a file:<\/p>\n<pre>takeown \/f <i>&lt;filename&gt;<\/i><\/pre>\n<p><i>Replace <\/i><b><i>&lt;filename&gt;<\/i><\/b><i> with the actual file name with the full path.<\/i><\/p>\n<p><em>The currently logged on user is now the owner of the file.<\/em><\/p>\n<p>To set <code>Administrators<\/code> group the owner of the file, use the <code>\/A<\/code> switch in addition:<\/p>\n<pre>takeown \/f <i>&lt;filename&gt; \/a<\/i><\/pre>\n<ul>\n<li><code>\/A<\/code> Gives ownership to the Administrators group instead of the current user. If <code>\/A<\/code> is not specified, file ownership will be given to the currently logged-on user. This parameter is <strong>not<\/strong> case-sensitive.<\/li>\n<\/ul>\n<p>If the operation was successful, you should see the following message:<\/p>\n<blockquote><p><i>&#8220;SUCCESS: The file (or folder): &#8220;filename&#8221; now owned by user &#8220;Computer Name\\User name&#8221;.&#8221;<\/i><\/p>\n<p>or<\/p>\n<p>SUCCESS: The file (or folder): &#8220;filename&#8221; now owned by the administrators group.<\/p><\/blockquote>\n<h3><a id=\"file_permissions\"><\/a>Assign File Permissions<\/h3>\n<p>Then to grant <b>Administrators<\/b> Full Control permissions for the file, use <b>ICACLS<\/b>. Here is the syntax:<\/p>\n<pre>icacls <i>&lt;filename&gt;<\/i> \/grant administrators:F<\/pre>\n<div class=\"qt\">\nNote: On non-English Windows installations, the error &#8220;No mapping between account names and security IDs was done&#8221; occurs when running the above command because the built-in admininstrator account name may be different in non-English versions. In that case, you can use the SID instead of the account name.<\/p>\n<p>Run:<\/p>\n<pre>icacls <i>&lt;filename&gt;<\/i> \/grant *S-1-5-32-544:F<\/pre>\n<p>The command works in English as well as non-English Windows OS.<\/p>\n<\/div>\n<p>Example 2: To assign Full Control permissions for the currently logged on user, use this command:<\/p>\n<pre>icacls <i>&lt;filename&gt;<\/i> \/grant %username%:F<\/pre>\n<p><i><b>%username%<\/b> represents the account name of the currently logged-on user. ICacls accepts this variable directly.<\/i><\/p>\n<p>Example 3: To assign Full Control permissions for the user named <code>John<\/code>, use this command:<\/p>\n<pre>ICACLS <i>&lt;filename&gt;<\/i> \/grant John:F<\/pre>\n<hr \/>\n<h3><a id=\"takeown_folder\"><\/a>Taking ownership of a folder<\/h3>\n<p>Use the following syntax:<\/p>\n<pre>takeown \/f <i>&lt;foldername&gt;<\/i><\/pre>\n<p>(or)<\/p>\n<pre>takeown \/f <i>&lt;foldername&gt; \/a<\/i><\/pre>\n<ul>\n<li><code>\/a<\/code> Gives ownership to the Administrators group instead of the current user. If <code>\/a<\/code> is not specified, ownership will be given to the currently logged-on user. This parameter is <strong>not<\/strong> case-sensitive.<\/li>\n<\/ul>\n<p>You&#8217;ll see the following output:<\/p>\n<blockquote><p>SUCCESS: The file (or folder): &#8220;folder_name&#8221; now owned by by user &#8220;computername\\username&#8221;<\/p>\n<p>(or)<\/p>\n<p>SUCCESS: The file (or folder): &#8220;folder_name&#8221; now owned by the administrators group.<\/p><\/blockquote>\n<h4>Change ownership recursively:<\/h4>\n<p>To change the ownership of a folder, its subfolders, and files in each subfolder, use this syntax:<\/p>\n<pre>takeown \/f <i>&lt;foldername&gt;<\/i> \/r \/d y<\/pre>\n<p><em>The currently logged on user is now the owner of the folder.<\/em><\/p>\n<p>To set <code>Administrators<\/code> group the owner of the folder, its subfolders, and files recursively, use the <code>\/A<\/code> switch in addition:<\/p>\n<pre>takeown \/f <i>&lt;foldername&gt; \/a \/r \/d y<\/i><\/pre>\n<ul>\n<li><code>\/R<\/code> Recurse: instructs the tool to operate on files in the specified directory and all subdirectories.<\/li>\n<li><code>\/D<\/code> prompt Default answer used when the current user does not have the &#8220;list folder&#8221; permission on a directory. This occurs while operating recursively (\/R) on sub-directories. Valid values &#8220;Y&#8221; to take ownership or &#8220;N&#8221; to skip.<\/li>\n<\/ul>\n<h3><a id=\"folder_permissions\"><\/a>Assign Folder Permissions<\/h3>\n<p>Then to assign the <b>Administrators<\/b> group Full Control Permissions for the folder, use this syntax:<\/p>\n<pre>icacls <i>&lt;foldername&gt;<\/i> \/grant administrators:F \/T<\/pre>\n<div class=\"qt\">\nNote: On non-English Windows installations, the error &#8220;No mapping between account names and security IDs was done&#8221; occurs when running the above command because the built-in admininstrator account name may be different in non-English versions. In that case, you can use the SID instead of the account name.<\/p>\n<p>Run:<\/p>\n<pre>icacls <i>&lt;foldername&gt;<\/i> \/grant *S-1-5-32-544:F \/T<\/pre>\n<p>The command works in English as well as non-English Windows OS.<\/p>\n<\/div>\n<p>The <b>\/T<\/b> parameter is added so that the operation is carried out through all the sub-directories and files within that folder.<\/p>\n<h4>Command-line help:<\/h4>\n<p>To know the complete usage information for Takeown.exe and ICacls.exe, run these commands from a Command Prompt window.<\/p>\n<pre><b>takeown \/?<\/b><\/pre>\n<pre><b>icacls \/?<\/b><\/pre>\n<hr \/>\n<h3><a id=\"tweaks\"><\/a>Easier Methods for Taking Ownership<\/h3>\n<h4>Command Script<\/h4>\n<p>To further simplify the process of taking ownership, <a href=\"http:\/\/blogs.msdn.com\/tims\/\" target=\"_blank\" rel=\"noopener noreferrer\">Tim Sneath<\/a> of Microsoft provides a .CMD file (Windows Command Script) which takes ownership and assigns Full Control Permissions to Administrators for the directory. For more information, read Tim&#8217;s post, titled <a href=\"https:\/\/docs.microsoft.com\/en-us\/archive\/blogs\/tims\/windows-vista-secret-11-deleting-the-undeletable\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Secret #11: Deleting the Undeletable<\/a>.<\/p>\n<h4>Add the &#8220;Take Ownership&#8221; command to the right-click menu<\/h4>\n<p>This again uses the special <i><b>runas<\/b><\/i> verb in Windows Vista and higher, which I&#8217;ve covered earlier (<b>REF<\/b> <i><a href=\"https:\/\/www.winhelponline.com\/blog\/?s=runas\">RunAs<\/a><\/i>).<\/p>\n<p>via <a href=\"http:\/\/www.winmatrix.com\/forums\/index.php?showtopic=13157\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">WinMatrix.com<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/takeown.gif\" width=\"214\" height=\"117\" border=\"0\" \/>Download <b><a href=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/takeown-contextmenu.reg\">takeown_context.reg<\/a><\/b> and save to Desktop. Right-click on the file and choose <b>Merge<\/b>. Click <b>Yes<\/b> when asked for confirmation. This adds an extended command named <b>Take Ownership<\/b> in the context menu for files and directories. To access the command, you need to press and hold the <b>SHIFT<\/b> key and then right-click on a file or folder.<\/p>\n<p><em>(You can read more about the tweak in the article <a href=\"https:\/\/www.winhelponline.com\/blog\/take-ownership-via-right-click-context-menu-add\/\">Take Ownership of File or Folder via Right-click Context Menu in Windows<\/a><\/em>.)<\/p>\n<hr \/>\n<h2>Additional Information<\/h2>\n<p>The above section covers most of the stuff you need. Read below if you need more tips on this topic.<\/p>\n<h3><a id=\"icacls_setowner\"><\/a>icacls.exe also can change ownership of a file or folder!<\/h3>\n<p>Takeown.exe and Icacls.exe are the two built-in console tools in Windows, that lets you change file or folder ownership and assign access control permissions, respectively. Takeown.exe sets the currently logged-in user account as the owner of an object (file or folder).<\/p>\n<p>However, with Takeown.exe, you can&#8217;t make another account as the owner of an object.<\/p>\n<p><em>Did you know that the icacls.exe tool can also be used to change ownership?<\/em><\/p>\n<p>To change the ownership to a third-party account (i.e., the account that&#8217;s not currently logged in) or group, you may use icacls.exe with the <code>\/setowner<\/code> command-line argument, instead of takeown.exe.<\/p>\n<h3>Change ownership of a file or folder using icacls.exe<\/h3>\n<p>We saw how to change the ownership using icacls.exe in the last part of the article <a href=\"https:\/\/www.winhelponline.com\/blog\/take-ownership-of-file-or-folder\/#trustedinstaller\">Take Ownership of a File or Folder Using Command-Line in Windows<\/a>. Here are some more examples:<\/p>\n<p>The following is the command-line syntax to change the ownership of a file or folder using icacls.exe:<\/p>\n<pre>icacls \"file_or_folder_name\" \/setowner \"NT Service\\TrustedInstaller\"<\/pre>\n<h4>Examples: Set #1: Change ownership of a single file or folder<\/h4>\n<pre>icacls \"D:\\Annual Reports\\2020\\November\" \/setowner \"John\"<\/pre>\n<pre>icacls \"D:\\Tax Audit\\November.xlsx\" \/setowner \"John\"<\/pre>\n<pre>icacls \"D:\\Tax Audit\\November.xlsx\" \/setowner \"Administrators\"<\/pre>\n<p>If the operation was successful, you&#8217;ll see the following message:<\/p>\n<pre>processed file: <em>file_or_folder_name<\/em>\nSuccessfully processed 1 files; Failed processing 0 files<\/pre>\n<h4>Example #2: Change ownership for a folder (subfolder, and files) recursively<\/h4>\n<p>To change the ownership of a folder, its subfolders, and all the files in all subfolders recursively, use the <code>\/T<\/code> switch (traverse) in addition:<\/p>\n<pre>icacls \"folder_name\" \/setowner \"Administrators\" \/T<\/pre>\n<ul>\n<li><code>\/T<\/code> indicates that this operation is performed on all matching files\/directories below the directories specified in the name.<\/li>\n<\/ul>\n<p>The above command sets TrustedInstaller as the owner of the folder, its subfolders, and all the files in all the subfolders.<\/p>\n<hr \/>\n<h3><a id=\"trustedinstaller\"><\/a>Revert the Ownership back to TrustedInstaller<\/h3>\n<p>Sometimes, to fix an issue, you may need to alter a <a href=\"https:\/\/www.winhelponline.com\/blog\/gpedit-resource-string-requireprivatestoreonly-windowsstore-admx-kb3147458\/\">data file<\/a> such as XML or a <a href=\"https:\/\/www.winhelponline.com\/blog\/fix-w7-backup-restore-acronis-true-image\/\">registry key<\/a> owned by TrustedInstaller. For that, you first need to take ownership of the file, folder, or <a href=\"https:\/\/www.winhelponline.com\/blog\/how-to-take-ownership-of-registry-keys-and-assign-full-permissions\/\">registry key<\/a>.<\/p>\n<p>After modifying the files or settings, you need to revert the ownership back to <strong>TrustedInstaller<\/strong>, if TrustedInstaller was the previous or original owner. To set the ownership back to TrustedInstaller, use these steps:<\/p>\n<p><em>The Windows Modules Installer service or TrustedInstaller enables the installation, modification, and removal of Windows updates and optional components. By default, TrustedInstaller is also the owner of many critical registry keys and system files.<\/em><\/p>\n<ol>\n<li>Right-click on a file or registry key, and click Permissions.<\/li>\n<li>Click Advanced to open the Advanced Security Settings dialog.<\/li>\n<li>Near &#8220;Owner:&#8221;, click Change.<\/li>\n<li>In the Select User or Group dialog, type &#8220;<code>NT SERVICE\\TrustedInstaller<\/code>&#8221; and press ENTER.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5263\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/05\/trustedinstaller-owner-1.png\" alt=\"take ownership of a file\" width=\"458\" height=\"252\" \/><\/li>\n<li>Click Apply, OK.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5262\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/05\/trustedinstaller-owner-2.png\" alt=\"take ownership of a file\" width=\"676\" height=\"287\" \/><\/li>\n<\/ol>\n<p>This changes the object&#8217;s ownership (file, folder, or <a href=\"https:\/\/www.winhelponline.com\/blog\/take-ownership-registry-key-permissions-command-line-acl\/\">registry key<\/a>) to TrustedInstaller or Windows Modules Installer.<\/p>\n<div class=\"rp\"><strong>RELATED:<\/strong> <a href=\"https:\/\/www.winhelponline.com\/blog\/take-ownership-registry-key-permissions-command-line-acl\/\">Take Ownership of a Registry Key &amp; Assign Permissions Using Command-line<\/a><\/div>\n<h4>Using icacls.exe command to set TrustedInstaller as the owner of a file<\/h4>\n<p>From an admin Command Prompt window, use the following command-line syntax:<\/p>\n<pre>icacls \"path\\filename\" \/setowner \"NT Service\\TrustedInstaller\"<\/pre>\n<p>Example:<\/p>\n<pre>icacls \"C:\\Windows\\PolicyDefinitions\\WindowsStore.admx\" \/setowner \"NT Service\\TrustedInstaller\"<\/pre>\n<p>TrustedInstaller now owns the file WindowsStore.admx.<\/p>\n<hr \/>\n<h3><a id=\"icacls_acc_denied\"><\/a>icacls \/setowner access denied?<\/h3>\n<p>Sometimes, the <code>icacls.exe \/setowner<\/code> command-line can encounter the following error:<\/p>\n<pre class=\"err\">filename: Access is denied.\nSuccessfully processed 0 files; Failed processing 1 files<\/pre>\n<p>This can happen when it encounters an NTFS hard link. The error usually pops up when you attempt to change ownership of protected files in the Windows directory &#8212; e.g., <code>C:\\Windows\\Notepad.exe<\/code>. A <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/fileio\/hard-links-and-junctions\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">hard link<\/a> is the file system representation of a file by which more than one path references a single file in the same volume.<\/p>\n<p>For example, the Notepad.exe files have two hard-linked files, which you can see using the following command:<\/p>\n<pre>fsutil.exe hardlink list C:\\Windows\\notepad.exe<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19933\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/05\/icacls-setowner-access-denied-hardlinks.png\" alt=\"fsutil hardlink list notepad.exe\" width=\"681\" height=\"156\" \/><\/p>\n<p>You can see that Notepad.exe is hard-linked to the following files:<\/p>\n<pre>C:\\Windows\\System32\\Notepad.exe\nC:\\\\Windows\\WinSxS\\amd64_microsoft-windows-notepad_31bf3856ad364e35_10.0.19041.488_none_4cea9379ceedab35\\notepad.exe<\/pre>\n<p>The <code>icacls.exe \/setowner<\/code> command encounters the <code>ACCESS_DENIED<\/code> error when processing these hard links.<\/p>\n<p><em>Note that the icacls.exe documentation says, &#8220;This option does not force a change of ownership; use the takeown.exe utility for that purpose.&#8221;<\/em><\/p>\n<p>If you encounter &#8220;Access is Denied&#8221; errors when setting ownership using Icacls, you may have to rely on Takeown.exe, SubInACL, or the third-party SetACL.exe (see next paragraph) command-line utility.<\/p>\n<hr \/>\n<h3><a id=\"setacl_owner_permissions\"><\/a>Using SetACL.exe to take ownership and assign permissions<\/h3>\n<p>SetACL.exe is a 3rd party command-line tool (from HelgeKlein.com) which we&#8217;ve covered <a href=\"https:\/\/www.winhelponline.com\/blog\/take-ownership-registry-key-permissions-command-line-acl\/\">before<\/a>.<\/p>\n<div class=\"qt\">\n<h4>SetACL: Command-line arguments<\/h4>\n<p>Before proceeding, let\u2019s see the command-line syntax for changing file\/registry ownership and permissions using SetACL.<\/p>\n<pre>SetACL -on objectname -ot objecttype -actn action<\/pre>\n<ul>\n<li><code>-on<\/code>: Specify the path to the object SetACL should operate on (e.g., file, registry key, network share, service, or printer).<\/li>\n<li><code>-ot<\/code>: Specify the object type. To change ownership or permissions for a file or folder, use the object type <code>file<\/code>. For registry keys, use the object type <code>reg<\/code><\/li>\n<li><code>-actn<\/code>: Specify the action as to what should SetACL do against the object specified. For taking ownership, set the action as <code>setowner<\/code>. To change permissions, set the action as <code>ace<\/code>.<\/li>\n<li><code>-ownr<\/code>: \u00a0Specify Name or SID of a trustee (a user or group) in this format &#8212; e.g., <code>\"n:Administrators\"<\/code><\/li>\n<\/ul>\n<p><em>(See <a href=\"https:\/\/helgeklein.com\/setacl\/documentation\/command-line-version-setacl-exe\/\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">SetACL documentation<\/a> for the full list of objects, types, and supported actions.)<\/em><\/p>\n<\/div>\n<p>To change ownership and grant full control permission, here are some examples:<\/p>\n<h4>Examples: Change ownership of a single file or folder:<\/h4>\n<pre>setacl.exe -on c:\\windows\\notepad.exe -ot file -actn setowner -ownr \"n:NT Service\\TrustedInstaller\"\nsetacl.exe -on c:\\windows\\notepad.exe -ot file -actn setowner -ownr \"n:Administrators\"\nsetacl.exe -on c:\\windows\\notepad.exe -ot file -actn setowner -ownr \"n:John\"\n\nsetacl.exe -on \"d:\\test\" -ot file -actn setowner -ownr \"n:NT Service\\TrustedInstaller\"\nsetacl.exe -on \"d:\\test\" -ot file -actn setowner -ownr \"n:Administrators\"\nsetacl.exe -on \"d:\\test\" -ot file -actn setowner -ownr \"n:John\"<\/pre>\n<h4>Examples: Change ownership recursively:<\/h4>\n<p><strong>Option 1:<\/strong> To set ownership of a folder and its subfolders (<strong>not for files<\/strong>) recursively, use one of these examples:<\/p>\n<pre>setacl.exe -on d:\\test -ot file -actn setowner -ownr \"n:NT Service\\TrustedInstaller\" -rec cont\nsetacl.exe -on d:\\test -ot file -actn setowner -ownr \"n:Administrators\" -rec cont\nsetacl.exe -on d:\\test -ot file -actn setowner -ownr \"n:Ramesh\" -rec cont<\/pre>\n<ul>\n<li><code>-rec<\/code> &#8211; recursion is enabled.<\/li>\n<li><code>cont<\/code> &#8211; Recurse, and process directories only.<\/li>\n<\/ul>\n<p><strong>Option 2:<\/strong> To set ownership of files in a folder and its subfolders (<strong>not folders<\/strong>) recursively, use one of these examples:<\/p>\n<pre>setacl.exe -on d:\\test -ot file -actn setowner -ownr \"n:NT Service\\TrustedInstaller\" -rec obj\nsetacl.exe -on d:\\test -ot file -actn setowner -ownr \"n:Administrators\" -rec obj\nsetacl.exe -on d:\\test -ot file -actn setowner -ownr \"n:Ramesh\" -rec obj<\/pre>\n<ul>\n<li><code>-rec<\/code> &#8211; recursion is enabled.<\/li>\n<li><code>obj<\/code> &#8211; Recurse, and process files only.<\/li>\n<\/ul>\n<p><strong>Option 3:<\/strong> To set ownership of a <strong>folder, its subfolders, and the files<\/strong>\u00a0recursively, use one of these examples:<\/p>\n<pre>setacl.exe -on d:\\test -ot file -actn setowner -ownr \"n:NT Service\\TrustedInstaller\" -rec cont_obj\nsetacl.exe -on d:\\test -ot file -actn setowner -ownr \"n:Administrators\" -rec cont_obj\nsetacl.exe -on d:\\test -ot file -actn setowner -ownr \"n:Ramesh\" -rec cont_obj<\/pre>\n<ul>\n<li><code>-rec<\/code> &#8211; recursion is enabled.<\/li>\n<li><code>cont_obj<\/code> &#8211; Recurse, and process directories and files.<\/li>\n<\/ul>\n<h4>Examples: Assign the required permissions for a file or folder:<\/h4>\n<p>Once you have the ownership, you can assign the required permissions for an object. Here are some examples:<\/p>\n<p>To assign the permissions for a <strong>single<\/strong> file or folder, use one of these examples:<\/p>\n<pre>setacl.exe -on \"d:\\test\\sample.xlsx\" -ot file -actn ace -ace \"n:Administrators;p:full\"\nsetacl.exe -on \"d:\\test\\sample.xlsx\" -ot file -actn ace -ace \"n:John;p:full\"\n\nsetacl.exe -on \"d:\\test\" -ot file -actn ace -ace \"n:Administrators;p:full\"\nsetacl.exe -on \"d:\\test\" -ot file -actn ace -ace \"n:John;p:full\"<\/pre>\n<h4>Examples:\u00a0Assign the required permissions recursively:<\/h4>\n<p><strong>Option 1:<\/strong> For a <strong>folder and subfolders<\/strong> (not files) recursively, use one of these examples:<\/p>\n<pre>setacl.exe -on \"d:\\test\" -ot file -actn ace -ace \"n:Administrators;p:full\" -rec cont\nsetacl.exe -on \"d:\\test\" -ot file -actn ace -ace \"n:John;p:full\" -rec cont<\/pre>\n<ul>\n<li><code>-rec<\/code> &#8211; recursion is enabled.<\/li>\n<li><code>cont<\/code> &#8211; Recurse, and process directories only.<\/li>\n<\/ul>\n<p><strong>Option 2:<\/strong> For files in a folder and subfolders (<strong>not folders<\/strong>) recursively, use one of these examples:<\/p>\n<pre>setacl.exe -on \"d:\\test\" -ot file -actn ace -ace \"n:Administrators;p:full\" -rec obj\nsetacl.exe -on \"d:\\test\" -ot file -actn ace -ace \"n:John;p:full\" -rec obj<\/pre>\n<ul>\n<li><code>-rec<\/code> &#8211; recursion is enabled.<\/li>\n<li><code>obj<\/code> &#8211; Recurse, and process files only.<\/li>\n<\/ul>\n<p><strong>Option 3:<\/strong> For a <strong>folder, its subfolders, and the files<\/strong> recursively, use one of these examples:<\/p>\n<pre>setacl.exe -on \"d:\\test\" -ot file -actn ace -ace \"n:Administrators;p:full\" -rec cont_obj\nsetacl.exe -on \"d:\\test\" -ot file -actn ace -ace \"n:John;p:full\" -rec cont_obj<\/pre>\n<ul>\n<li><code>-rec<\/code> &#8211; recursion is enabled.<\/li>\n<li><code>cont_obj<\/code> &#8211; Recurse, and process directories and files.<\/li>\n<\/ul>\n<p>You may check out SetACL official documentation to know about its full capabilities.\u00a0However, to set file and folder ownership &amp; permissions, takeown.exe and icacls.exe would be more than sufficient for most users.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every file or folder in an NTFS volume has an owner. Certain system files are owned by TrustedInstaller, some by SYSTEM account, and others by the &#8220;Administrators&#8221; group. If a user creates a file or folder, that user is usually the owner of the file or folder. The owner is the one who can assign &#8230; <a title=\"Change Ownership of a File or Folder Using Takeown Command-Line Tool\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/take-ownership-of-file-or-folder\/\" aria-label=\"Read more about Change Ownership of a File or Folder Using Takeown Command-Line Tool\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[250,577],"class_list":["post-264","post","type-post","status-publish","format-standard","hentry","category-windows","tag-icacls","tag-takeown"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":9058,"url":"https:\/\/www.winhelponline.com\/blog\/failed-to-enumerate-objects-in-the-container-ownership\/","url_meta":{"origin":264,"position":0},"title":"Fix: &#8220;Failed to Enumerate Objects in the Container&#8221; Error","author":"Ramesh","date":"May 6, 2019","format":false,"excerpt":"When you try to open a folder, you may see the message \"You don't currently have permission to access this folder.\u00a0Click Continue to permanently get access to this folder.\" Clicking on the Continue shows the message \"You have been denied permission to access this folder.\u00a0To gain access to this folder\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"failed to enumerate objects in the container - change ownership recursively sub-folders","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/05\/w10-safe-mode-win-re.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":10223,"url":"https:\/\/www.winhelponline.com\/blog\/take-ownership-registry-key-permissions-command-line-acl\/","url_meta":{"origin":264,"position":1},"title":"Take Ownership of Registry Key &#038; Assign Permissions Using Command-line","author":"Ramesh","date":"July 7, 2019","format":false,"excerpt":"We've seen how to use the Registry Editor (regedit.exe) to change ownership of a registry key and subkeys. This article tells you how to change registry key ownership and grant permissions using the command-line. Windows has the takeown.exe and icacls.exe console utilities to change file\/folder ownership and permissions, but there\u2026","rel":"","context":"In &quot;Utilities&quot;","block_context":{"text":"Utilities","link":"https:\/\/www.winhelponline.com\/blog\/category\/utilities\/"},"img":{"alt_text":"take ownership registry command-line - setacl trustedinstaller","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/take-ownership-registry-command-line-recursively.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/take-ownership-registry-command-line-recursively.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/07\/take-ownership-registry-command-line-recursively.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4021,"url":"https:\/\/www.winhelponline.com\/blog\/take-ownership-via-right-click-context-menu-add\/","url_meta":{"origin":264,"position":2},"title":"Take Ownership of File or Folder via Right-click Menu","author":"Ramesh","date":"September 6, 2016","format":false,"excerpt":"We saw how to Take Ownership of a file or folder using the takeown.exe command-line tool. You can add the \"Take Ownership\" command to the right-click menu to make it easier to access. Add \"Take Ownership\" to the right-click menu Download take_ownership_context_menu.zip, unzip the file, and run the enclosed REG\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"take ownership - success - check status","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/takeown_results_cmd.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/takeown_results_cmd.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/takeown_results_cmd.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/takeown_results_cmd.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":19688,"url":"https:\/\/www.winhelponline.com\/blog\/compressed-zip-folder-error-file-not-found-no-read-permission\/","url_meta":{"origin":264,"position":3},"title":"Compressed (Zipped) Folder Error &#8220;File not found or no read permission&#8221;","author":"Ramesh","date":"November 4, 2020","format":false,"excerpt":"When you try to create a compressed (zipped) folder in Windows 10, the following error occurs: Compressed (zipped) Folders Error File not found or no read permission. You may have noticed that this error doesn't happen on drives formatted as FAT32.\u00a0This article explains why this problem occurs and how to\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"compressed folder create error - no read permissions - process explorer","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2020\/11\/procexp-find-locked-files.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2020\/11\/procexp-find-locked-files.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2020\/11\/procexp-find-locked-files.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":34390,"url":"https:\/\/www.winhelponline.com\/blog\/error-1310-writing-file-access-directory\/","url_meta":{"origin":264,"position":4},"title":"Error 1310: Error writing to file; Verify access to that directory","author":"Ramesh","date":"March 14, 2023","format":false,"excerpt":"When you try to install a program, the installer may encounter the error 1310. The error code 1310 means \"Error attempting to create the destination file.\" Error 1310. Error writing to file: <filename> Verify that you have access to that directory. Cause The error 1310 occurs if the installer cannot\u2026","rel":"","context":"In &quot;Utilities&quot;","block_context":{"text":"Utilities","link":"https:\/\/www.winhelponline.com\/blog\/category\/utilities\/"},"img":{"alt_text":"error 1310 windows installer","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2023\/03\/error-1310-installer.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1193,"url":"https:\/\/www.winhelponline.com\/blog\/fix-zipped-folder-access-denied-unable-complete-operation\/","url_meta":{"origin":264,"position":5},"title":"[Fix] Compressed (Zipped) Folder Access Denied Error &#8220;Unable to Complete the Operation&#8221;","author":"Ramesh","date":"October 27, 2012","format":false,"excerpt":"When you try to create a Compressed (zipped) folder in Windows, the error \"Unable to complete the operation. Access is denied\" may occur and the zip file is not created. Compressed (Zipped) Folder Access Denied error occurs if the user %TEMP% variable isn't properly set, or the user has no\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"temp variable set - zip folder access denied","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2012\/10\/zip-fldr-access-denied.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=264"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/264\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}