Add Take Ownership to Context Menu in Windows 10  

Page 52 of 64 FirstFirst ... 242505152535462 ... LastLast

  1. Posts : 3
    Win 10
       #510

    Thank you, that was like fastest answer ever. I tried to Take Ownership of whole WindowsApps folder and I got 80k successes and 188 failures. Guess in which group is my game folder located? I just need to paste two files into it. Can you give me any more advice on how to approach this?
      My Computer


  2. Posts : 68,994
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #511

    Lukyz said:
    Thank you, that was like fastest answer ever. I tried to Take Ownership of whole WindowsApps folder and I got 80k successes and 188 failures. Guess in which group is my game folder located? I just need to paste two files into it. Can you give me any more advice on how to approach this?
    You could try to also take ownership of the game folder to see if it may allow you to save files into it.
      My Computers


  3. Posts : 3
    Win 10
       #512

    Of course I tried that. Whole WindowsApp folder, then game folder and then individual files within the game folder, all without success. I even tried to boot up Ubuntu and copy files this way but OS see those game folders like corrupted files. I'm really lost here and to be honest, I really don't like this "Apple" practice when I'm told which files on my system I can or cannot access. But it seems I lost this one. Anyway, thank you for your tips.
      My Computer


  4. Posts : 91
    10 pro
       #513

    Double entries


    I installed the 9/18/2019 version, but it produces TWO "Take ownership" entries on context menus for most directories (folders). And yes, I ran your "remove" script first to delete any entries from the previous version.
      My Computer


  5. Posts : 68,994
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #514

    SpacemanSam said:
    I installed the 9/18/2019 version, but it produces TWO "Take ownership" entries on context menus for most directories (folders). And yes, I ran your "remove" script first to delete any entries from the previous version.

    Hello Sam,

    Go ahead an upload and attach the old version. I'll take a look at it, and post back a .reg file that undo and remove all of it so you can use the new version.
      My Computers


  6. Posts : 91
    10 pro
       #515

    Brink said:
    Hello Sam,

    Go ahead and upload and attach the old version. I'll take a look at it, and post back a .reg file that undo and remove all of it so you can use the new version.
    Never mind - I found the problem.
    I added your current version to a master file containing all of the context menu tweaks I apply to every new build, but when I replaced the old version of "Take ownership" with the new version I missed a section. The file deleted the old version then immediately reapplied part of it.

    Once I found that and fixed it, it works properly.


    Here's a fix you should include: Your code is hard-coded to block the Users directory on C:. I never put/leave the Users directory (or anything else containing any data that needs to be backed up) on the system drive. That way, I can reformat the system drive and reinstall the OS without losing anything. The following batch file fixes this problem:
    Code:
    REM Install "Take ownership"
    REG IMPORT "%~dp0Add_Take_Ownership_with_Pause_to_context_menu.reg"
    REM Get path to "Users" directory.
    FOR /F "tokens=2*" %%P IN ('REG QUERY "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" /V "ProfilesDirectory" ^| find /i "REG_"') DO set ProfPath=%%Q
    REM Fix the "AppliesTo" values for "Take ownership" to use the correct paths taken from the current Environment
    REG ADD "HKLM\SOFTWARE\Classes\Directory\shell\TakeOwnership" /V "AppliesTo" /T REG_SZ /D "NOT (System.ItemPathDisplay:=\"%ProfPath%\\\" OR System.ItemPathDisplay:=\"%ProgramData%\" OR System.ItemPathDisplay:=\"%SystemRoot%\" OR System.ItemPathDisplay:=\"%SystemRoot%\\System32\" OR System.ItemPathDisplay:=\"%ProgramFiles%\" OR System.ItemPathDisplay:=\"%ProgramFiles(x86)%\")" /F
    REG ADD "HKLM\SOFTWARE\Classes\Drive\shell\runas" /V "AppliesTo" /T REG_SZ /D "NOT (System.ItemPathDisplay:=\"%SystemDrive%\\\")" /F
    In addition, this code uses the environment variables for the locations of the other directories that should be protected from "take ownership". (I have never seen a Windows installation where the OS was installed anywhere else but C:, but I prefer to use defined pointers to things than hard-coding whenever possible, just to be safe.)
    You could, of course, convert the .reg file to a .bat file so the whole thing would be in just one file.
    You might even be able to do something in the .bat file to fix the localization problem: Read the user's language code from the registry, then use that to select the appropriate letter that means "Yes" in that language. There might even be something in one of the Windows localization files that will provide the right letter.
      My Computer


  7. Posts : 68,994
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #516

    @SpacemanSam,

    I tested using variables for the "AppliesTo" value, but they no longer stopped the "Take Ownership" context menu showing for those items.
      My Computers


  8. Posts : 91
    10 pro
       #517

    Brink said:
    @SpacemanSam,

    I tested using variables for the "AppliesTo" value, but they no longer stopped the "Take Ownership" context menu showing for those items.
    Did you put the environment variables in a .bat file as I specified, or did you put them in the .reg file?
    If you put them in the .reg file, the environment variable names are inserted literally into the registry. I tested it tonight to confirm it, and it doesn't work if you do that. You need to use a .bat file so the environment variables will be expanded by CMD before being inserted into the registry. It works when you do it that way.
    Also, %ProfPath% is not a built-in environment variable. You need to execute the REG QUERY command to read it from HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList.
      My Computer


  9. Posts : 68,994
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #518

    SpacemanSam said:
    Did you put the environment variables in a .bat file as I specified, or did you put them in the .reg file?
    If you put them in the .reg file, the environment variable names are inserted literally into the registry. I tested it tonight to confirm it, and it doesn't work if you do that. You need to use a .bat file so the environment variables will be expanded by CMD before being inserted into the registry. It works when you do it that way.
    Also, %ProfPath% is not a built-in environment variable. You need to execute the REG QUERY command to read it from HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList.

    Ah, got it. Yep, I applied via .reg instead of .bat.
      My Computers


  10. Posts : 91
    10 pro
       #519

    Brink said:
    Ah, got it. Yep, I applied via .reg instead of .bat.
    I've continued to add to the .bat file. It now does everything your separate .reg files do, including automatic localization for 3 languages (English, French and Spanish). I'm currently doing this via a stack of "IF"s like this:

    Code:
    REM Install "Take ownership" and other context menu items
    @TITLE %~nx0
    
    REM Add "Take Ownership" to context menus
    REM Created by: Shawn Brink
    REM Updated on: September 18th 2019
    REM Tutorial: https://www.tenforums.com/tutorials/3841-add-take-ownership-context-menu-windows-10-a.html
    
    REM To pause before execution, enable this line
    REM SET PauseBefore=PAUSE ^& & SET PauseBeforePS=PAUSE ^^^&
    
    REM To pause after execution, enable this line
    SET PauseAfter= ^& PAUSE& SET PauseAfterPS= ^^^& PAUSE
    
    REM To pause after execution only if error, enable this line
    REM SET PauseAfter= ^|^| PAUSE& SET PauseAfterPS= ^^^|^^^| PAUSE
    
    REM Position in context menu
    REM Permissible values are top, middle and bottom
    SET Position=middle
    
     @Rem ********** End of user-configurable options. ***********
    
    openfiles >NUL: 2>&1 || (
        REM Command failed => no admin rights
        @echo This script must be run as administrator!  Press any key to exit... & PAUSE >NUL:
        exit /b 2
    )
    
    REM Get Windows' Installed Language.
    FOR /F "tokens=2*" %%P IN ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language" /V "Default" ^| find /i "REG_"') DO set Language=%%Q
    
    @ECHO Language = %Language%
    
    REM English: Yes
    IF %Language% EQU 0409 SET Yes=Y
    
    REM French: Oui
    IF /I %Language% EQU 040C SET Yes=O
    
    REM Spanish: Si
    IF /I %Language% EQU 0C0A SET Yes=S
    
    REM Add more languages here
    
    IF NOT DEFINED Yes @ECHO I don't know what language %Language% is.  You'll have to add it. & PAUSE & EXIT /B 2
    
    REM Get path to "Users" directory.
    FOR /F "tokens=2*" %%P IN ('REG QUERY "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" /V "ProfilesDirectory" ^| find /i "REG_"') DO set ProfPath=%%Q
    
    REM Delete any old versions
    REG delete "HKLM\Software\Classes\*\shell\TakeOwnership" /f
    REG delete "HKLM\Software\Classes\*\shell\runas" /f
    REG delete "HKLM\Software\Classes\dllfile\shell\runas" /f
    REG delete "HKLM\Software\Classes\Directory\shell\runas" /f
    REG delete "HKLM\Software\Classes\Directory\shell\TakeOwnership" /f
    REG delete "HKLM\Software\Classes\Drive\shell\runas" /f
    
    REG add "HKLM\Software\Classes\*\shell\runas" /ve /t REG_SZ /d "Take Ownership" /f
    REG add "HKLM\Software\Classes\*\shell\runas" /v "Icon" /t REG_SZ /d "C:\Windows\System32\imageres.dll,-78" /f
    REG delete "HKLM\Software\Classes\*\shell\runas" /v "Extended" /f
    REG add "HKLM\Software\Classes\*\shell\runas" /v "HasLUAShield" /t REG_SZ /d "" /f
    REG add "HKLM\Software\Classes\*\shell\runas" /v "NoWorkingDirectory" /t REG_SZ /d "" /f
    REG add "HKLM\Software\Classes\*\shell\runas" /v "Position" /t REG_SZ /d "%Position%" /f
    REG add "HKLM\Software\Classes\*\shell\runas\command" /ve /t REG_SZ /d "cmd.exe /c %PauseBefore% takeown /f "%%1" && icacls "%%1" /GRANT *S-1-3-4:F /c /l%PauseAfter%" /f
    REG add "HKLM\Software\Classes\*\shell\runas\command" /v "IsolatedCommand" /t REG_SZ /d "cmd.exe /c %PauseBefore% takeown /f "%%1" && icacls "%%1" /GRANT *S-1-3-4:F /c /l%PauseAfter%" /f
    
    REG add "HKLM\Software\Classes\Directory\shell\TakeOwnership" /ve /t REG_SZ /d "Take Ownership" /f
    REG ADD "HKLM\SOFTWARE\Classes\Directory\shell\TakeOwnership" /V "AppliesTo" /T REG_SZ /D "NOT (System.ItemPathDisplay:="%ProfPath%\\" OR System.ItemPathDisplay:="%ProgramData%" OR System.ItemPathDisplay:="%SystemRoot%" OR System.ItemPathDisplay:="%SystemRoot%\\System32" OR System.ItemPathDisplay:="%ProgramFiles%" OR System.ItemPathDisplay:="%ProgramFiles(x86)%")" /F
    REG delete "HKLM\Software\Classes\Directory\shell\TakeOwnership" /v "Extended" /f
    REG add "HKLM\Software\Classes\Directory\shell\TakeOwnership" /v "HasLUAShield" /t REG_SZ /d "" /f
    REG add "HKLM\Software\Classes\Directory\shell\TakeOwnership" /v "NoWorkingDirectory" /t REG_SZ /d "" /f
    REG add "HKLM\Software\Classes\Directory\shell\TakeOwnership" /v "Position" /t REG_SZ /d "%Position%" /f
    REG add "HKLM\Software\Classes\Directory\shell\TakeOwnership\command" /ve /t REG_SZ /d "powershell -windowstyle hidden -command "Start-Process cmd -ArgumentList '/c %PauseBeforePS% takeown /f \\"%%1\\" /r /d %Yes% ^&^& icacls \\"%%1\\" /grant *S-1-3-4:F /t /c /l /q%PauseAfterPS%' -Verb runAs"" /f
    REG add "HKLM\Software\Classes\Directory\shell\TakeOwnership\command" /v "IsolatedCommand" /t REG_SZ /d "powershell -windowstyle hidden -command "Start-Process cmd -ArgumentList '/c %PauseBeforePS% takeown /f \\"%%1\\" /r /d %Yes% ^&^& icacls \\"%%1\\" /grant *S-1-3-4:F /t /c /l /q%PauseAfterPS%' -Verb runAs"" /f
    
    REG add "HKLM\Software\Classes\Drive\shell\runas" /ve /t REG_SZ /d "Take Ownership" /f
    REG delete "HKLM\Software\Classes\Drive\shell\runas" /v "Extended" /f
    REG add "HKLM\Software\Classes\Drive\shell\runas" /v "HasLUAShield" /t REG_SZ /d "" /f
    REG add "HKLM\Software\Classes\Drive\shell\runas" /v "NoWorkingDirectory" /t REG_SZ /d "" /f
    REG add "HKLM\Software\Classes\Drive\shell\runas" /v "Position" /t REG_SZ /d "%Position%" /f
    REG add "HKLM\Software\Classes\Drive\shell\runas" /v "AppliesTo" /t REG_SZ /d "NOT (System.ItemPathDisplay:="%SystemDrive%\\")" /f
    REG add "HKLM\Software\Classes\Drive\shell\runas\command" /ve /t REG_SZ /d "cmd.exe /c %PauseBefore% takeown /f "%%1\\" /r /d %Yes% && icacls "%%1\\" /grant *S-1-3-4:F /t /c%PauseAfter%" /f
    REG add "HKLM\Software\Classes\Drive\shell\runas\command" /v "IsolatedCommand" /t REG_SZ /d "cmd.exe /c %PauseBefore% takeown /f "%%1\\" /r /d %Yes% && icacls "%%1\\" /grant *S-1-3-4:F /t /c%PauseAfter%" /f
    
    EXIT /B 0
    I would prefer to read the localized word for "Yes" from a Windows resource file such as shell32.dll so it would work automatically in whichever language is installed. But I haven't yet found out how to do that. Do you have any tutorials (or links to other websites) that would be useful?
    Last edited by SpacemanSam; 09 Nov 2019 at 14:12.
      My Computer


 

Tutorial Categories

Add Take Ownership 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 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 12:57.
Find Us




Windows 10 Forums