memstechtips / UnattendedWinstall

Personalized Unattended Answer Files that helps automatically debloat and customize Windows 10 & 11 during the installation process.
MIT License
1.12k stars 169 forks source link

[Feature Request]: Add "Take Ownership" option to the right click context menu #13

Closed Hanamizaki closed 5 days ago

Hanamizaki commented 1 week ago

Thank you for your work on this project it has made reinstalling windows a lot simpler for me.

If I would have anything to request it would be the "Take Ownership" option on the right click context menu, it helps with deleting or moving certain windows files and folders that are just an annoyance. There are already a few scripts that do this so it should be possible to implement hopefully.

Once again thank you for your work.

memstechtips commented 1 week ago

Thanks for your feedback and suggestion! I'm glad you find the project useful.

I'm sure I can add something like that yeah. Could you maybe link some resources I can look at in the meantime? Like these scripts you're talking about.

slowstuff commented 1 week ago

Here are the registry settings I use to add "Take Ownership" to all files and most directories.

; Clears any previous entry
[-HKEY_CLASSES_ROOT\*\shell\TakeOwnership]

; Adds Take Ownership context menu for files
[HKEY_CLASSES_ROOT\*\shell\TakeOwnership]
@="Take Ownership"
"Extended"=-
"HasLUAShield"=""
"NoWorkingDirectory"=""
"NeverDefault"=""

; Command that gets run by TakeOwnership for files
[HKEY_CLASSES_ROOT\*\shell\TakeOwnership\command]
@="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" && icacls \\\"%1\\\" /grant *S-1-3-4:F /t /c /l' -Verb runAs\""
"IsolatedCommand"= "powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c takeown /f \\\"%1\\\" && icacls \\\"%1\\\" /grant *S-1-3-4:F /t /c /l' -Verb runAs\""

; Adds Take Ownership context menu for directories (Prevents a few directories to keep from breaking system)
[HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership]
@="Take Ownership"
"AppliesTo"="NOT (System.ItemPathDisplay:=\"C:\\Windows\" OR System.ItemPathDisplay:=\"C:\\Windows\\System32\" OR System.ItemPathDisplay:=\"C:\\ProgramData\")"
"Extended"=-
"HasLUAShield"=""
"NoWorkingDirectory"=""
"Position"="middle"

; Command that gets run by TakeOwnership for directories (Also changes owner of all files and folders within)
[HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership\command]
@="powershell -windowstyle hidden -command \"$Y = ($null | choice).Substring(1,1); Start-Process cmd -ArgumentList ('/c takeown /f \\\"%1\\\" /r /d ' + $Y + ' && icacls \\\"%1\\\" /grant *S-1-3-4:F /t /c /l /q') -Verb runAs\""
"IsolatedCommand"="powershell -windowstyle hidden -command \"$Y = ($null | choice).Substring(1,1); Start-Process cmd -ArgumentList ('/c takeown /f \\\"%1\\\" /r /d ' + $Y + ' && icacls \\\"%1\\\" /grant *S-1-3-4:F /t /c /l /q') -Verb runAs\""

Hope it helps.

memstechtips commented 6 days ago

Thanks, will test it out sometime.

memstechtips commented 5 days ago

Just added this feature with help from this post