Add "take ownership" context menu

This is not working, and I don't have enough experience to troubleshoot, so I would like some help
This commit is contained in:
Yuri Gabriel
2024-02-18 15:31:59 -03:00
parent c842584cfe
commit 253ebc864c
2 changed files with 67 additions and 3 deletions

View File

@ -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.",