GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Feature: "Take Ownership" of a file or folder?

New item for the wishlist: Take Ownership

In Win7, permissions can get messed up, so that it sometimes becomes hard to delete a file or folder, requiring the user to take ownership of the file, even if he is already admin with UAC disabled.

At present, taking ownership of a file or folder takes the long and winding road: Properties / Security / Advanced / Owner / Edit / (click on owner name) / check "Replace owner on subcontainers and objects" / Apply.

A few days ago, I was inspired by a thread by newguy with a screenshot where "Take Ownership" lives in the context menu.
As later clarified on the thread, the feature is implemented by a registry patch.

On the one hand, that is easy enough for any interested party to implement.
On the other hand,

  1. Taking ownership of a file is a file operation, so that could seem to be in the "bull's eye" of Opus's core functionality;
  2. When using Opus for troubleshooting a strange person's machine (using Opus on USB), it would be nice to have "Take Ownership" at one's fingertips on right-click, rather than to have to patch the registry.

Therefore, if others share this interest, I wonder if it would be practical for our amazing Team Opus to implement this feature as part of the application.

Wishing you all a fun weekend.


Ppl shouldn't necessarily fear modifying the registry as long as you're able to understand what a reg tweak is and isn't doing...

If the solution at the site you linked to is otherwise likeable to you, it'd be trivial to create Opus buttons or Opus context menu items for the same. I don't recall Windows XP having some of the utilities this reg tweak is calling - but all its doing is adding context menu entries to call (now) native OS command line tools (takeown / icacls).

Hi Steje,

Thank you for sharing your insights about this.
Am I making this up, or did you use to have a cool avatar with wandering ants?

Yes, I like the solution on that site very much.

I had never looked at the content of a reg file, but your comment incited me to open this one up. It looks less intimidating than I had feared.

There are a few lines in that reg file. I was expecting for there to be two commands---one with the syntax to take ownership of files, one with the syntax to take ownership of folders. But maybe there are more.

Not having looked closely at the shell since the days of DOS 3.0, it may take me a while to figure out how to translate that into a single Opus command to stick into a button or in the context menu. If this stuff is second nature to you or someone else who is reading, I'll be really grateful if you'd give me a push... Otherwise no worries, I'll experiment with it in a few days. :smiley:

@="Take ownership"

@="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"

@="Take ownership"

@="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"

@="Take ownership"

@="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F"

@="Take ownership"

@="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant administrators:F /t"

Happy Friday!


I have to imagine that there is a good reason (maybe specific to doing it through the registry) that they duplicated the same commands a few times for both "all objects" and "exe" and "dll" files specifically... and then a slightly different command line needed for recursing through directories. But I don't think you need to do the same for adapting it to run from Opus.

So, here are two Opus button definitions... one for files, and the other for folders. You can paste these definitions directly to any toolbar and just use these commands as buttons - or after doing so just to get a look at the commands inside the buttons, you can then use the commands in your own context menu entries. The command for "files" would be added to the "All files" category in the Opus File Types editor, while the command for "folders" would naturally be added to the "All folders" category.


<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Take Ownership (Files)</label> <icon1>#adminmode</icon1> <function type="batch"> <instruction>cmd.exe /c takeown /f {f} &amp;&amp; icacls {f} /grant administrators:F</instruction> <instruction>pause</instruction> </function> </button>


<?xml version="1.0"?> <button backcol="none" display="both" separate="yes" textcol="none"> <label>Take Ownership (Folders)</label> <icon1>#adminmode</icon1> <function type="batch"> <instruction>cmd.exe /c takeown /f {f} /r /d y &amp;&amp; icacls {f} /grant administrators:F /t</instruction> <instruction>pause</instruction> </function> </button>

Hi steje,

Thank you so much for searching through the hay to separate the commands for files and for folders.
Thank you also for telling me to implement the context menu through the File Type preferences. I would not have thought of this and would have fumbled under Customize / Context.

I made the context menu entries following your instructions, and it works beautifully.
Now when I export to USB, these preferences should carry---will try that later.

For anyone who would like a touch more detail about implementing the Context menu solution (rather than buttons), here is the "long version" of steje's instructions (unless I am mistaken).

Context for Files
0. Settings / File Types (or Prefs / File Types if you are using my Menu toolbar)

  1. click on "NONE (All Files)"
  2. click the Edit button
  3. select the Context Menu tab
  4. click New
  5. Work with the fields as follows:
    Action box: "Own This" (if you already have another Take Ownership installed) or "Take Ownership"
    Icon box (the small square to the right of Action): click, type "admin" in the filter, select the admin mode icon
    Function pull-down menu: MS-DOS Batch function
    Command box: paste this:

cmd.exe /c takeown /f {f} icacls {f} /grant administrators:F pause
Context for Folders
Same steps as for files, except:
At step 1, select "(NONE) All Folders"
At step 5, in the Command box, paste:

cmd.exe /c takeown /f {f} /r /d y icacls {f} /grant administrators:F /t pause
Wishing you all a beautiful weekend.

Update: I'd like to keep this feature on the Wish List because...

  1. It is a file operation.
  2. Today I bought an Opus Pro license for a friend. (I'm pretty confident he'll love it and pay me back.)
    This means that I'm now managing 4 Opus installation (the 3 on my dual license) and my friend's.
    To get "Take Ownership" to work, I pretty much have to set it up on each machine (unless I start messing with the OCB). It would be better if it worked out of the box.

But if it doesn't make sense to add it to the interface from a development standpoint, no worries.

I use the free Winbubble program for these (and other) tweaks. Simply Google for the URL

How would I apply this Take Ownership command to an entire disk? In my case, I have a dozen USB sticks and MicroSDs that frequently end up with permissions issues due to OS re-installs, account renames, and other chaos. :laughing:

I saw that context menus for hard drive must be compatible between Opus and Explorer, but don't understand what are the implications for a disk wide takeover function. I tried several iterations using Standard function: Opus or External but still don't have a working drive wide "take ownership"...

Bonus points if the function would automatically exit with an error if accidentally launched on the system drive... :smile:

# in /bin/bash that would be something like...
if %SystemDrive% == "{f}"; then
  echo "WARNING: dude... don't do this to your boot drive..." && exit
# and then the actual permissions fix...
takeown /f {f} /r /d y
icacls {f} /grant administrators:F /t

Can't wait until Linux shell completely replaces these crazy ".bat" files... :speak_no_evil:

Which part isn't working that you need help with? The commands themselves, or getting them to appear in the menu for drives, or something else?

You don't have to use .bat files/syntax. You can use javascript for conditional logic if needed.


I'm using:

Settings > File Types > System File Types > Drive > Context Menu, and then added a new Take Ownership context menu item.

Action: Take Ownership (all files)
Function: Standard Function (Opus or External)
Command: @admin cmd.exe /c takeown /f {f} /r /d y && icacls {f} /grant administrators:F /t && pause

However the context menu item doesn't show up when I right click on a Drive in an Opus lister showing This PC or when I click on a disk in the File Tree on the left.

Also, once the context menu item is showing up and the takeown & icalcs grant is working, I would also like to short-circuit the command if the selected drive is %SystemDrive%.

Leo, any feedback on how to make a drive level "take ownership " command?

This PC uses Explorer-wrapped view by default instead of Opus-native view. You can toggle that in Preferences / Folders / Virtual Folders. That should make your Opus-specific context menus available there (at the expense of different visual style of This PC).

Alternatively, you could be able to add your command as "Run an application...." (which is available both in Opus and Explorer) instead of "Run an Opus function" (which is not available in Explorer), something like this:


I guess similar situation applies to the File Tree (which I don't use so I don't know).

It would be nice if there is a customizable context menu for drives one day. It should mix in what has been defined in the context menu of folders as far as things make sense, since a drive is also a folder.

Entries like "Backup this Drive", "Unmount", "Copy UNC Path", "Disconnect", "Spin Down", "Switch off", "Show other mountpoints", "Create ShadowCopy (RestorePoint)", "Clean tmp+logs" etc. would really make sense and fun. o)