Question/help about take ownership context menu - excluding ext device

Page 1 of 2 12 LastLast

  1. Posts : 20
    Win 10 Pro x64 21H1
       #1

    Question/help about take ownership context menu - excluding ext device


    Hello and Merry Christmas

    Can someone help me to modify "take ownership" context menu to thing i wanna achieve?

    I want to modify this reg to make windows take ownership context menu not appear on any device that is not my physical internal drive and exclude from appearing in for example on usb thumb stick or cd/dvd drive or sd card and so on

    This reg below is slightly modified of tutorial link to my liking
    Add Take Ownership to Context Menu in Windows 10

    Code:
    Windows Registry Editor Version 5.00
    
    ; Created by: Shawn Brink
    ; Created on: January 28, 2015
    ; Updated on: January 11, 2021
    ; Tutorial: https://www.tenforums.com/tutorials/3841-add-take-ownership-context-menu-windows-10-a.html
    
    
    
    [-HKEY_CLASSES_ROOT\*\shell\TakeOwnership]
    [-HKEY_CLASSES_ROOT\*\shell\runas]
    
    [HKEY_CLASSES_ROOT\*\shell\TakeOwnership]
    @="take full control admin v2"
    "Extended"=-
    "HasLUAShield"=""
    "NoWorkingDirectory"=""
    "NeverDefault"=""
    
    [HKEY_CLASSES_ROOT\*\shell\TakeOwnership\command]
    @="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" && icacls \\\"%1\\\" /grant :r administrators:F /t /c /l /remove:g BUILTIN && attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" & attrib -r -s -h -i \"%1\\*.*\" /s /d' -Verb runAs\""
    "IsolatedCommand"="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" && icacls \\\"%1\\\" /grant :r administrators:F /t /c /l /remove:g BUILTIN && attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" & attrib -r -s -h -i \"%1\\*.*\" /s /d' -Verb runAs\""
    
    [HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership]
    @="take full control admin v2"
    "AppliesTo"="NOT (System.ItemPathDisplay:=\"C:\\Users\" OR System.ItemPathDisplay:=\"C:\\ProgramData\" OR System.ItemPathDisplay:=\"C:\\Windows\" OR System.ItemPathDisplay:=\"C:\\Windows\\System32\" OR System.ItemPathDisplay:=\"C:\\Program Files\" OR System.ItemPathDisplay:=\"C:\\Program Files (x86)\")"
    "Extended"=-
    "HasLUAShield"=""
    "NoWorkingDirectory"=""
    "Position"="middle"
    
    [HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership\command]
    @="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" /r /d y && icacls \\\"%1\\\" /grant :r administrators:F /t /c /l /q /remove:g BUILTIN && attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" & attrib -r -s -h -i \"%1\\*.*\" /s /d' -Verb runAs\""
    "IsolatedCommand"="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" /r /d y && icacls \\\"%1\\\" /grant :r administrators:F /t /c /l /q /remove:g BUILTIN && attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" & attrib -r -s -h -i \"%1\\*.*\" /s /d' -Verb runAs\""
    
    [HKEY_CLASSES_ROOT\Drive\shell\runas]
    @="take full control admin v2"
    "Extended"=-
    "HasLUAShield"=""
    "NoWorkingDirectory"=""
    "Position"="middle"
    "AppliesTo"="NOT (System.ItemPathDisplay:=\"C:\\\")"
    
    [HKEY_CLASSES_ROOT\Drive\shell\runas\command]
    @="cmd.exe /c takeown /f \"%1\\\" /r /d y && icacls \"%1\\\" /grant :r administrators:F /t /c /remove:g BUILTIN && attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" & attrib -r -s -h -i \"%1\\*.*\" /s /d"
    "IsolatedCommand"="cmd.exe /c takeown /f \"%1\\\" /r /d y && icacls \"%1\\\" /grant :r administrators:F /t /c /remove:g BUILTIN && attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" && cmd /c attrib -r -s -h -i \"%1\" & attrib -r -s -h -i \"%1\\*.*\" /s /d"

    I can see there is "AppliesTo" thing that excludes context menu from appearing on different C locations
    but i want to context menu not appear additionally on anything that is not internal drive for example:

    1. I want context menu to appear on windows HDD/SSD on regardless of number of partitions: ex: C D E F G ... that belongs to internal HDD/SSD of PC

    2. I dont want this context menu appear on things like:
    - plugged in removable sd card
    - plugged in removable any phone/smartphone/gps device and so on
    - plugged in removable usb thumb stick
    - plugged in removable external HDD/SSD/HYBRID drive
    - internal CD/DVD drive in my tower (connecteby sata)
    - any other plugged in removable usb devices

    *3. Additionally i want this context menu to work on different language OS than English (currently testing this on English only os but i want it to work on different OS that have different naming of system folders (for example Program FIies folder is Eine Programme on different language OS)

    I was looking into it for some time and couldnt find an answer even though script from tutorial has lines that excludes some C system folders from menu appearing.

    OS: Win 10 x64 Pro 22H2 Build 19045.2965

    Thanks and Merry Christmas for everyone
      My Computer


  2. Posts : 8,114
    windows 10
       #2

    As in effect its copyright it would be nice to ask permission first I am sure Brink wouldnt mind
      My Computer


  3. Posts : 43,029
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #3

    Be very careful about what you wish Santa Claus to bring you... did you note this in the tutorial?

    The Take Ownership 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 taking ownership of the Windows "C:" drive and these specific system folders can make Windows unstable as it would also take ownership of all their content at the same time.
    @Brink
    Hi Shawn, I'd guess @Milky Window would value your thoughts... thanks!
      My Computers


  4. Posts : 20
    Win 10 Pro x64 21H1
    Thread Starter
       #4

    Then i ask for permission since i dont know how to do it other way than typing here.
      My Computer


  5. Posts : 43,029
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #5

    And thank you for your reply. Please wait for Brink's comment.
      My Computers


  6. Posts : 20
    Win 10 Pro x64 21H1
    Thread Starter
       #6

    The Take Ownership 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 taking ownership of the Windows "C:" drive and these specific system folders can make Windows unstable as it would also take ownership of all their content at the same time.

    Yes i noticed this in tutorial. Since i wanted to try to make same thing to not appear on external/additional devices like i described before.
      My Computer


  7. Posts : 68,999
    64-bit Windows 11 Pro for Workstations
       #7

    Hello,

    I'm afraid it would be a choice of all or none for internal vs removable drives for the context menu.

    I'm not aware of a way to make it compatible for any language since the "Yes" (Y) parameter in the commands are language specific.
      My Computers


  8. Posts : 20
    Win 10 Pro x64 21H1
    Thread Starter
       #8

    Brink said:
    Hello,

    I'm afraid it would be a choice of all or none for internal vs removable drives for the context menu.

    I'm not aware of a way to make it compatible for any language since the "Yes" (Y) parameter in the commands are language specific.
    Ok i understand about language compatibility. Sorry but did not understood your first sentence - do you mean it is not possible at all or it is possible but solution could be incomplete and "context menu" could appear on lets say "some strange device attached"?
      My Computer


  9. Posts : 68,999
    64-bit Windows 11 Pro for Workstations
       #9

    I'm not aware of a way to have the context menu show for all drives except removable drives.
      My Computers


  10. Posts : 20
    Win 10 Pro x64 21H1
    Thread Starter
       #10

    Ok. Thanks guys for answers. I will try to find a way/workaround and will post here if I find something useful.
      My Computer


 

  Related Discussions
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 08:42.
Find Us




Windows 10 Forums