From 253ebc864c11701da2e01376528a04d4ccf40b0b Mon Sep 17 00:00:00 2001 From: Yuri Gabriel <97139700+Yuuh15@users.noreply.github.com> Date: Sun, 18 Feb 2024 15:31:59 -0300 Subject: [PATCH] Add "take ownership" context menu This is not working, and I don't have enough experience to troubleshoot, so I would like some help --- config/tweaks.json | 32 ++++++++++++++++++++++++++++++++ winutil.ps1 | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/config/tweaks.json b/config/tweaks.json index 9f9bfb9f..aac5f5f0 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -2546,6 +2546,38 @@ "Disable-NetAdapterBinding -Name \"*\" -ComponentID ms_tcpip6" ] }, + "WPFTweaksTakeOwnershipContextMenu": { + "Content": "Enable Take Ownership in context menu", + "Description": "Enables Take Ownership in file explorer context menu. Useful if windows is being fussy with external drives.", + "category": "z__Advanced Tweaks - CAUTION", + "panel": "1", + "Order": "a031_", + "InvokeScript": [ + " + New-Item -Path \"Registry::HKCR:\\*\\shell\\runas\" -Force | Out-Null + Set-ItemProperty -Path \"Registry::HKCR:\\*\\shell\\runas\" -Name \"(default)\" -Value 'Take Ownership' + Set-ItemProperty -Path \"Registry::HKCR:\\*\\shell\\runas\" -Name \"NoWorkingDirectory\" -Value '' + + New-Item -Path \"Registry::HKCR:\\*\\shell\\runas\\command\" -Force | Out-Null + Set-ItemProperty -Path \"Registry::HKCR:\\*\\shell\\runas\\command\" -Name \"(default)\" -Value 'cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F' + Set-ItemProperty -Path \"Registry::HKCR:\\*\\shell\\runas\\command\" -Name \"IsolatedCommand\" -Value 'cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F' + + New-Item -Path \"Registry::HKCR:\\Directory\\shell\\runas\" -Force | Out-Null + Set-ItemProperty -Path \"Registry::HKCR:\\Directory\\shell\\runas\" -Name \"(default)\" -Value 'Take Ownership' + Set-ItemProperty -Path \"Registry::HKCR:\\Directory\\shell\\runas\" -Name \"NoWorkingDirectory\" -Value '' + + New-Item -Path \"Registry::HKCR:\\Directory\\shell\\runas\\command\" -Force | Out-Null + Set-ItemProperty -Path \"Registry::HKCR:\\Directory\\shell\\runas\\command\" -Name \"(default)\" -Value 'cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t' + Set-ItemProperty -Path \"Registry::HKCR:\\Directory\\shell\\runas\\command\" -Name \"IsolatedCommand\" -Value 'cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t' + " + ], + "UndoScript": [ + " + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path \"Registry::HKCR:\\*\\shell\\runas\" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path \"Registry::HKCR:\\Directory\\shell\\runas\" + " + ] + }, "WPFToggleDarkMode": { "Content": "Dark Theme", "Description": "Enable/Disable Dark Mode.", diff --git a/winutil.ps1 b/winutil.ps1 index 3e750be9..29f44aaa 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -10,7 +10,7 @@ Author : Chris Titus @christitustech Runspace Author: @DeveloperDurp GitHub : https://github.com/ChrisTitusTech - Version : 24.02.07 + Version : 24.02.18 #> param ( [switch]$Debug, @@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "24.02.07" +$sync.version = "24.02.18" $sync.configs = @{} $sync.ProcessRunning = $false @@ -7660,7 +7660,7 @@ $sync.configs.applications = '{ "WPFInstallintelpresentmon": { "category": "Utilities", "choco": "na", - "content": "Intel? PresentMon", + "content": "Intel?? PresentMon", "description": "A new gaming performance overlay and telemetry application to monitor and measure your gaming experience.", "link": "https://game.intel.com/us/stories/intel-presentmon/", "winget": "Intel.PresentMon.Beta" @@ -10622,6 +10622,38 @@ $sync.configs.tweaks = '{ "Disable-NetAdapterBinding -Name \"*\" -ComponentID ms_tcpip6" ] }, + "WPFTweaksTakeOwnershipContextMenu": { + "Content": "Enable Take Ownership in context menu", + "Description": "Enables Take Ownership in file explorer context menu. Useful if windows is being fussy with external drives.", + "category": "z__Advanced Tweaks - CAUTION", + "panel": "1", + "Order": "a031_", + "InvokeScript": [ + " + New-Item -Path \"Registry::HKCR:\\*\\shell\\runas\" -Force | Out-Null + Set-ItemProperty -Path \"Registry::HKCR:\\*\\shell\\runas\" -Name \"(default)\" -Value ''Take Ownership'' + Set-ItemProperty -Path \"Registry::HKCR:\\*\\shell\\runas\" -Name \"NoWorkingDirectory\" -Value '''' + + New-Item -Path \"Registry::HKCR:\\*\\shell\\runas\\command\" -Force | Out-Null + Set-ItemProperty -Path \"Registry::HKCR:\\*\\shell\\runas\\command\" -Name \"(default)\" -Value ''cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F'' + Set-ItemProperty -Path \"Registry::HKCR:\\*\\shell\\runas\\command\" -Name \"IsolatedCommand\" -Value ''cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F'' + + New-Item -Path \"Registry::HKCR:\\Directory\\shell\\runas\" -Force | Out-Null + Set-ItemProperty -Path \"Registry::HKCR:\\Directory\\shell\\runas\" -Name \"(default)\" -Value ''Take Ownership'' + Set-ItemProperty -Path \"Registry::HKCR:\\Directory\\shell\\runas\" -Name \"NoWorkingDirectory\" -Value '''' + + New-Item -Path \"Registry::HKCR:\\Directory\\shell\\runas\\command\" -Force | Out-Null + Set-ItemProperty -Path \"Registry::HKCR:\\Directory\\shell\\runas\\command\" -Name \"(default)\" -Value ''cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t'' + Set-ItemProperty -Path \"Registry::HKCR:\\Directory\\shell\\runas\\command\" -Name \"IsolatedCommand\" -Value ''cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t'' + " + ], + "UndoScript": [ + " + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path \"Registry::HKCR:\\*\\shell\\runas\" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path \"Registry::HKCR:\\Directory\\shell\\runas\" + " + ] + }, "WPFToggleDarkMode": { "Content": "Dark Theme", "Description": "Enable/Disable Dark Mode.",