Add Change Owner to Context Menu in Windows 10  

Page 1 of 2 12 LastLast
    Add Change Owner to Context Menu in Windows 10

    Add Change Owner to Context Menu in Windows 10

    Published by Category: User Accounts
    21 Mar 2020
    Designer Media Ltd

    How to Add Change Owner to Context Menu in Windows 10


    An owner is assigned to an object when that object is created. By default, the owner is the creator of the object. No matter what permissions are set on an object, the owner of the object can always change the permissions.

    The owner of an object (ex: file, folder, drive, or registry key) has the right to allow or deny access to that resource. Although members of the Administrators group and other authorized users also have the right to allow or deny access, the owner has the authority to lock out non-administrator users, and then the only way to regain access to the resource is for an administrator or a member of the Restore Operators group to take ownership of it. This makes the file or folder owner important with respect to what permissions are allowed or denied for a given resource.

    Ownership can be taken or transferred in several ways. The current owner of an object can transfer ownership to another user or group. A member of the Administrators group can take ownership of an object or transfer ownership to another user or group—even if administrators are locked out of the resource according to the permissions. Any user with the "Take Ownership" permission on the object can take ownership, as can any member of the "Backup Operators" group (or anyone else with the "Restore Files And Directories" user right, for that matter).

    This tutorial will show you how to add Change Owner to the context menu of all files, folders, and drives for all users in Windows 10.

    The Change Owner context menu will allow you to quickly and easily see which user or group is the current user of a file, folder, or drive.

    The Change Owner context menu will also allow you to instantly change the owner of a file, folder (including contents), or drive to Administrators, Everyone, SYSTEM, or TrustedInstaller on demand.

    This can be handy if you had previously changed the owner of a file, folder or drive, and wanted to restore the owner back to Administrators, Everyone, SYSTEM, or TrustedInstaller.

    When you right click or press and hold on a file, folder, or drive, click/tap on Change Owner, and click/tap on either one of the the Change Owner to... items, you will be prompted by UAC to approve.

    The Change Owner context menu will not be available when you right click or press and hold only on the specific C: drive, C:\Program Files folder, C:\Program Files (x86) folder, C:\ProgramData folder, C:\Users folder, and C:\Windows folder. This was done by design since changing the owner of the Windows "C:" drive and these specific system folders can make Windows unstable as it would also change the owner of the folder's content at the same time.

    You will still be able to use the Change Owner context menu on files and folders inside the locations above, and on all drives other than the C drive and FAT32 drives.

    You must be an administrator to add, remove, and use the Change Owner context menu.

    You do not need to be an administrator though to use the See Current Owner item in the "Change Owner" context menu.
    Add Change Owner to Context Menu in Windows 10-current_owner.png


    Changing the owner of a file, folder, or drive will not change its permissions.



    EXAMPLE: Change Owner context menu
    Add Change Owner to Context Menu in Windows 10-change_owner_context-menu.png



    Here's How:

    1 Do step 2 (add), step 3 (add w/pause), or step 4 (remove) below for what you would like to do.


    2 To Add "Change Owner" to Context Menu

    A) Click/tap on the Download button below to download the .reg file you want below, and go to step 5 below.

    Add_Change_Owner_to_context_menu.reg

    Download

    OR

    Add_Shift+Right-click_Change_Owner_to_context_menu.reg

    Download


    3 To Add "Change Owner" with Pause to Context Menu

    This option pauses the command when you use the "Change Owner" context menu to be able to see the command results. This can be handy to verify if changing ownership was successfully processed or not.

    Add Change Owner to Context Menu in Windows 10-with_pause.png

    A) Click/tap on the Download button below to download the .reg file you want below, and go to step 5 below.

    Add_Change_Owner_with_pause_to_context_menu.reg

    Download

    OR

    Add_Shift+Right-click_Change_Owner_with_pause_to_context_menu.reg

    Download


    4 To Remove "Change Owner" from Context Menu

    This is the default setting.

    A) Click/tap on the Download button below to download the .reg file below, and go to step 5 below.

    Remove_Change_Owner_from_context_menu.reg

    Download


    5 Save the .reg file to your Desktop.

    6 Double click/tap on the downloaded .reg file to merge it.

    7 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.

    8 When finished, you can delete the downloaded .reg file if you like.


    That's it,
    Shawn




  1. Posts : 46
    10 pro
       #1

    How do you do it?


    This is great! I'll add this to my Windows setup files.

    A lot of your additions add things to HKEY_CLASSES_ROOT. Where can I find documentation on how to do that? I'd like to write some of my own. I have about 50 years experience as a professional programmer, but it's rather hard to write code without adequate documentation of what's what. I tried a Google search, on HKEY_CLASSES_ROOT, but came up with nothing useful. A Google search on "add commands to right-click menu" was somewhat more helpful, but still did not give all the details of what the various keys and values are.
    Last edited by SpacemanSam; 21 Mar 2020 at 21:07.
      My Computer

  2. Brink's Avatar
    Posts : 49,780
    64-bit Windows 10 Pro for Workstations build 20161
    Thread Starter
       #2

    SpacemanSam said:
    This is great! I'll add this to my Windows setup files.

    A lot of your additions add things to HKEY_CLASSES_ROOT. Where can I find documentation on how to do that? I'd like to write some of my own. I have about 50 years experience as a professional programmer, but it's rather hard to write code without adequate documentation of what's what. I tried a Google search, on HKEY_CLASSES_ROOT, but came up with nothing useful. A Google search on "add commands to right-click menu" was somewhat more helpful, but still did not give all the details of what the various keys and values are.
    Hey mate,

    I'm sure there must be a ton of reference out there somewhere, but I don't think I've seen a all-in-one type reference for this yet. Most of what I know on this is from years of trial and error along with a general understanding of the registry.

    Real basically, you can add the entries for the context menu usually to the shell key for the file type or GUID of items you want usually in the HKEY_CLASSES_ROOT (aka: HKCR).

    For now, I'd say search for "context menu" in the tutorial index at the link below. You can download the .reg files for them, and edit them to compare to help get a feel for doing this.

    Windows 10 Tutorial Index

    In addition, here's a basic tutorial below for creating a cascading context menu that may help some more.

    Context Menu - Create Cascading Menu of Multiple Layers - Windows 7 Help Forums

    I'll be happy to help work with you on creating some until you get the hang of it if you like. Just create a new thread for one, and let me know the post link.
      My Computers


  3. Posts : 46
    10 pro
       #3

    I've been adding some enhancements to your "Change owner" tweak. Among other things, I've added your "Take Ownership" as a flyout item. I've got most of it working but I still have a few unanswered questions:
    1. What is the significance / function of the "01" in the "01Owner" key?
    2. How do you produce a separator in a sub-menu? I tried adding the list of sub-keys to the "SubCommands" value as DanSitar said to do in his tutorial on cascading menus, but that caused it to fail completely. As my code currently stands, two of the menus (directories and drives) have separators but one (files) doesn't, and I haven't found anything in the code that appears to account for it.
    3. How do you specify what order the entries in a flyout appear in?
    4. Two of the 3 "Take Ownership" entries add values to "...\TakeOwnership\runas" instead of just "...\TakeOwnership". What is the purpose of runas?
    5. What is the purpose of "...\ChangeOwner\shell\Administrators" > "CommandFlags"? CommandFlags appears nowhere else in this code.
    6. What is "IsolatedCommand"?
    7. Where can I read documentation on the syntax, etc. of the "AppliesTo" value? I want to add "Documents and Settings" (and perhaps a few others) to the list of prohibited directories, as this causes problems. Or perhaps changing ownership of ALL junctions should be prohibited?

    I can send you my code as it now stands if you need to examine it, but I have more I plan on adding once I get these bugs ironed out (such as adding flyouts for some of your other tweaks regarding ownership and permissions, to keep the size of the main right-click menu from becoming too excessive). I will definitely post the code (with comments, of course!) when it's finished.
      My Computer

  4. Matthew Wai's Avatar
    Posts : 2,371
    Windows 10 Home 1903
       #4

    SpacemanSam said:
    4. Two of the 3 "Take Ownership" entries add values to "...\TakeOwnership\runas" instead of just "...\TakeOwnership". What is the purpose of runas?
    I cannot find "TakeOwnership" in "Add_Change_Owner_to_context_menu.reg". What file are you referring to?

    SpacemanSam said:
    1. What is the significance / function of the "01" in the "01Owner" key?
    "01" denotes the first one. You may add the second one "02Owner" if need be.
      My Computer

  5. Brink's Avatar
    Posts : 49,780
    64-bit Windows 10 Pro for Workstations build 20161
    Thread Starter
       #5

    SpacemanSam said:
    I've been adding some enhancements to your "Change owner" tweak. Among other things, I've added your "Take Ownership" as a flyout item. I've got most of it working but I still have a few unanswered questions:
    1. What is the significance / function of the "01" in the "01Owner" key?
    2. How do you produce a separator in a sub-menu? I tried adding the list of sub-keys to the "SubCommands" value as DanSitar said to do in his tutorial on cascading menus, but that caused it to fail completely. As my code currently stands, two of the menus (directories and drives) have separators but one (files) doesn't, and I haven't found anything in the code that appears to account for it.
    3. How do you specify what order the entries in a flyout appear in?
    4. Two of the 3 "Take Ownership" entries add values to "...\TakeOwnership\runas" instead of just "...\TakeOwnership". What is the purpose of runas?
    5. What is the purpose of "...\ChangeOwner\shell\Administrators" > "CommandFlags"? CommandFlags appears nowhere else in this code.
    6. What is "IsolatedCommand"?
    7. Where can I read documentation on the syntax, etc. of the "AppliesTo" value? I want to add "Documents and Settings" (and perhaps a few others) to the list of prohibited directories, as this causes problems. Or perhaps changing ownership of ALL junctions should be prohibited?

    I can send you my code as it now stands if you need to examine it, but I have more I plan on adding once I get these bugs ironed out (such as adding flyouts for some of your other tweaks regarding ownership and permissions, to keep the size of the main right-click menu from becoming too excessive). I will definitely post the code (with comments, of course!) when it's finished.
    1) As Matthew already posted, "O1" in the key name is used for the order of the items in the context menu. The key name can be anything you want, but it will be listed in numeric order first and alphabetical order after any numbers. I just found it easier to use something like "O1" at the front of the key name to make it easy to arrange the order how I wanted.

    2) You would add the "CommandFlags"=dword:00000020 value in the second item between the two items you want a separator line at. You can see an example of its usage in the Add_Change_Owner_to_context_menu.reg here.

    3) Same as 1 with the key names per item.

    4) The "runas" key allows the item to prompt for elevation (run as administrator) without having to include a prompt for elevation in the command. You have to be careful about using the "runas" key since Windows uses for some file types, and using it will replace whatever was previously using it. This is one reason why I don't use the "runas" key unless it's not already used by default.

    5) Explained in 2 for the separator.

    6) I currently can't find a technical reference for the "IsolatedCommand" value for a better explanation, but it's used here as part of the command.

    7) I currently can't find a technical reference for the "AppliesTo" value for a better explanation, but it's basically a way to specify the context menu item to "NOT" appear for specified locations (ex: folders, drive letters. etc...). Think of it as an exclusion list.

    For example, I used the "System.ItemPathDisplay" property with "AppliesTo" to specify folder and drive paths to "NOT" appear for in this Add_Change_Owner_to_context_menu.reg file.

    I ended up eventually learning more about 6 & 7 by seeing examples of registry keys and values using it, and eventually putting 2 and 2 together about their purpose. A lot of trial and error. LOL

    EDIT: Sure, you can go ahead and create a new separate thread if you wanted to post your code for us to look at.


    Matthew Wai said:
    I cannot find "TakeOwnership" in "Add_Change_Owner_to_context_menu.reg". What file are you referring to?
    Hello Matthew,

    He's referring to the tutorial below for the take ownership bit he added to his custom .reg file.

    Add Take Ownership to Context Menu in Windows 10
      My Computers


  6. Posts : 46
    10 pro
       #6

    I am trying to merge your "Take ownership" tweak from Add Take Ownership to Context Menu in Windows 10 to this one. (Sorry, I forgot to give the URL in my original post.)
    The flyout structure I want to create is:

    See Current Owner
    ---------------------------
    Take Ownership
    Change Owner to Administrator
    Change Owner to Everyone
    Change Owner to SYSTEM
    Change Owner to TrustedInstaller
    ----------------------------
    List Permissions >
    Advanced Security

    The last two will be for your tweaks "List Permissions" Add List Permissions Context Menu in Windows and "Add Advanced security" Add Advanced security to Context Menu in Windows 8 and 10
    I want to get it working properly with "Take ownership" first before I add the last two.

    Your original code produces flyouts that look correct, but when I added "Take ownership", they aren't correct any more. I haven't been able to figure out what went wrong. I've tried various things such as putting "02" in front of "Take ownership", but that still isn't entirely correct. Depending on what I try, "Take ownership" appears either above the separator or several lines below, or sometimes there's no separator.

    Here's the first few lines of the file, showing what I added to the "*" (file) section:
    Code:
    ; Delete any old values
    [-HKEY_CLASSES_ROOT\*\shell\ChangeOwner]
    
    ; For files
    [HKEY_CLASSES_ROOT\*\shell\ChangeOwner]
    "MUIVerb"="Change Owner"
    "Extended"=-
    "HasLUAShield"=""
    "SubCommands"=""
    
    
    [HKEY_CLASSES_ROOT\*\shell\ChangeOwner\shell\01Owner]
    @="See Current Owner"
    "Icon"="imageres.dll,-1029"
    
    [HKEY_CLASSES_ROOT\*\shell\ChangeOwner\shell\01Owner\command]
    @="powershell -NoExit Get-ACL '%1'| Format-List -Property Owner"
    
    ;------ adapted from "Take Ownership" tutorial
    [HKEY_CLASSES_ROOT\*\shell\ChangeOwner\shell\runas]
    @="Take Ownership"
    "HasLUAShield"=""
    "NoWorkingDirectory"=""
    "Position"="middle"
    
    [HKEY_CLASSES_ROOT\*\shell\ChangeOwner\shell\runas\command]
    @="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant *S-1-3-4:F /c /l"
    "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant *S-1-3-4:F /c /l"
    ;---------- end added code
    
    [HKEY_CLASSES_ROOT\*\shell\ChangeOwner\shell\Administrators]
    @="Change Owner to Administrators"
    "HasLUAShield"=""
    "CommandFlags"=dword:00000020
    
    [HKEY_CLASSES_ROOT\*\shell\ChangeOwner\shell\Administrators\command]
    @="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%1\\\" /setowner \"Administrators\" /t /c /l' -Verb runAs\""
    "IsolatedCommand"="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%1\\\" /setowner \"Administrators\" /t /c /l' -Verb runAs\""
    "Take Ownership" works properly; it's just the flyout that doesn't look the way I want it to.
      My Computer

  7. Brink's Avatar
    Posts : 49,780
    64-bit Windows 10 Pro for Workstations build 20161
    Thread Starter
       #7

    @SpacemanSam,

    Personally, it may be best to keep them as separate context menus considering "Take Ownership" uses the "runas" key for part of it, and doesn't work the same or at all if tried to merge within the same keys used for this "Change Owner" context menu.
      My Computers


  8. Posts : 46
    10 pro
       #8

    So it seems. I was hoping to merge them, as they logically "belong" together, the only difference from the user's viewpoint being who the owner becomes.

    Also the right-click menu is already rather large and this would help reduce the clutter.

    What is the purpose of using "runas" ? Maybe if I understood this better I might be able to solve this! The documentation I've found so far has been too vague and confusing, and much of it seems to refer to a different context.
      My Computer

  9. Brink's Avatar
    Posts : 49,780
    64-bit Windows 10 Pro for Workstations build 20161
    Thread Starter
       #9

    SpacemanSam said:
    So it seems. I was hoping to merge them, as they logically "belong" together, the only difference from the user's viewpoint being who the owner becomes.

    Also the right-click menu is already rather large and this would help reduce the clutter.

    What is the purpose of using "runas" ? Maybe if I understood this better I might be able to solve this! The documentation I've found so far has been too vague and confusing, and much of it seems to refer to a different context.
    I agree. I have never really found any clear and concise reference material on this. Everything I've seen is pretty vague, and assumes you already fully know about the subject.

    Think of a command under the "runas" key as being the same as using the "Run as administrator" context menu on an executable file.

    If it's not under the "runas" key, you would have to programmatically prompt for elevation in the command code instead like in the other keys not under "runas" in the .reg file here.

    I used "runas" for the "HKEY_CLASSES_ROOT\*" key (generic all file types) for "Take Ownership" since I found it problematic to use the other way for this.
      My Computers


 

Tutorial Categories

Add Change Owner to Context Menu in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


Related Threads
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:23.
Find Us




Windows 10 Forums