Hi, I wanted to know, how can I copy and backup the default permissions before making changes to system files, folders etc including most ardent ones like System volume information which I can restore later. And while we're at it, how can I obtain the permissions for such objects which do not display current owner like system volume information ? Any help will be greatly appreciated. Thanks.
Reset Permissions into Right-click menu Spoiler: reg Code: Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\ResetPermissions] "HasLUAShield"="" "MUIVerb"="Reset Permissions " "NoWorkingDirectory"="" "Position"="middle" "SubCommands"="" [HKEY_CLASSES_ROOT\Directory\shell\ResetPermissions\shell] [HKEY_CLASSES_ROOT\Directory\shell\ResetPermissions\shell\001flyout] "HasLUAShield"="" "MUIVerb"="Reset permissions of this folder only" [HKEY_CLASSES_ROOT\Directory\shell\ResetPermissions\shell\001flyout\command] @="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%1\\\" /reset' -Verb runAs\"" [HKEY_CLASSES_ROOT\Directory\shell\ResetPermissions\shell\002flyout] "HasLUAShield"="" "MUIVerb"="Reset permissions of this folder, subfolders and files" [HKEY_CLASSES_ROOT\Directory\shell\ResetPermissions\shell\002flyout\command] @="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%1\\\" /reset /t /c /l' -Verb runAs\"" [HKEY_CLASSES_ROOT\*\shell\ResetPermissions] "MUIVerb"="Reset Permissions" "HasLUAShield"="" [HKEY_CLASSES_ROOT\*\shell\ResetPermissions\Command] @="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%1\\\" /reset' -Verb runAs\"" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\ResetPermissions] "MUIVerb"="Reset Permissions" "HasLUAShield"="" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\ResetPermissions\Command] @="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%1\\\" /reset' -Verb runAs\"" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\ResetPermissions] "HasLUAShield"="" "MUIVerb"="Reset Permissions " "NoWorkingDirectory"="" "Position"="middle" "SubCommands"="" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell] [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\001flyout] "HasLUAShield"="" "MUIVerb"="Reset permissions of this folder only" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\001flyout\command] @="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%1\\\" /reset' -Verb runAs\"" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\002flyout] "HasLUAShield"="" "MUIVerb"="Reset permissions of this folder, subfolders and files" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\002flyout\command] @="powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%1\\\" /reset /t /c /l' -Verb runAs\"" or .bat file (Run as administrator) Spoiler: .bat Code: @Echo Off Title Reg Converter v1.2 & Color 1A cd %systemroot%\system32 call :IsAdmin Reg.exe add "HKCR\Directory\shell\ResetPermissions" /v "HasLUAShield" /t REG_SZ /d "" /f Reg.exe add "HKCR\Directory\shell\ResetPermissions" /v "MUIVerb" /t REG_SZ /d "Reset Permissions " /f Reg.exe add "HKCR\Directory\shell\ResetPermissions" /v "NoWorkingDirectory" /t REG_SZ /d "" /f Reg.exe add "HKCR\Directory\shell\ResetPermissions" /v "Position" /t REG_SZ /d "middle" /f Reg.exe add "HKCR\Directory\shell\ResetPermissions" /v "SubCommands" /t REG_SZ /d "" /f Reg.exe add "HKCR\Directory\shell\ResetPermissions\shell\001flyout" /v "HasLUAShield" /t REG_SZ /d "" /f Reg.exe add "HKCR\Directory\shell\ResetPermissions\shell\001flyout" /v "MUIVerb" /t REG_SZ /d "Reset permissions of this folder only" /f Reg.exe add "HKCR\Directory\shell\ResetPermissions\shell\001flyout\command" /ve /t REG_SZ /d "powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%%1\\\" /reset' -Verb runAs\"" /f Reg.exe add "HKCR\Directory\shell\ResetPermissions\shell\002flyout" /v "HasLUAShield" /t REG_SZ /d "" /f Reg.exe add "HKCR\Directory\shell\ResetPermissions\shell\002flyout" /v "MUIVerb" /t REG_SZ /d "Reset permissions of this folder, subfolders and files" /f Reg.exe add "HKCR\Directory\shell\ResetPermissions\shell\002flyout\command" /ve /t REG_SZ /d "powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%%1\\\" /reset /t /c /l' -Verb runAs\"" /f Reg.exe add "HKCR\*\shell\ResetPermissions" /v "MUIVerb" /t REG_SZ /d "Reset Permissions" /f Reg.exe add "HKCR\*\shell\ResetPermissions" /v "HasLUAShield" /t REG_SZ /d "" /f Reg.exe add "HKCR\*\shell\ResetPermissions\Command" /ve /t REG_SZ /d "powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%%1\\\" /reset' -Verb runAs\"" /f Reg.exe add "HKLM\SOFTWARE\Classes\*\shell\ResetPermissions" /v "MUIVerb" /t REG_SZ /d "Reset Permissions" /f Reg.exe add "HKLM\SOFTWARE\Classes\*\shell\ResetPermissions" /v "HasLUAShield" /t REG_SZ /d "" /f Reg.exe add "HKLM\SOFTWARE\Classes\*\shell\ResetPermissions\Command" /ve /t REG_SZ /d "powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%%1\\\" /reset' -Verb runAs\"" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions" /v "HasLUAShield" /t REG_SZ /d "" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions" /v "MUIVerb" /t REG_SZ /d "Reset Permissions " /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions" /v "NoWorkingDirectory" /t REG_SZ /d "" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions" /v "Position" /t REG_SZ /d "middle" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions" /v "SubCommands" /t REG_SZ /d "" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\001flyout" /v "HasLUAShield" /t REG_SZ /d "" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\001flyout" /v "MUIVerb" /t REG_SZ /d "Reset permissions of this folder only" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\001flyout\command" /ve /t REG_SZ /d "powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%%1\\\" /reset' -Verb runAs\"" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\002flyout" /v "HasLUAShield" /t REG_SZ /d "" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\002flyout" /v "MUIVerb" /t REG_SZ /d "Reset permissions of this folder, subfolders and files" /f Reg.exe add "HKLM\SOFTWARE\Classes\Directory\shell\ResetPermissions\shell\002flyout\command" /ve /t REG_SZ /d "powershell -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/c icacls \\\"%%1\\\" /reset /t /c /l' -Verb runAs\"" /f Exit :IsAdmin Reg.exe query "HKU\S-1-5-19\Environment" If Not %ERRORLEVEL% EQU 0 ( Cls & Echo You must have administrator rights to continue ... Pause & Exit ) Cls goto:eof
Thank you @kaljukass. Highly appreciated. If I'm not wrong, this will reset the permissions of the folders I run this on to the default irrespective of how I mess with the ownership and permissions before ?
It should restore Windows default permissions for folders, subfolder and files. Simple right click to file or folder and then is possible to select for example for only this folder or also for all subfolders and files. This is Windows default function, here is only how to add it to right-click menu to run restore default permissions as simply as possible. Screenshots Spoiler
Thanks for clearing it up. Just one more question, will it also revert back the ownership, if I had snatched it from System ? or do I have to manually add that ?
Yep I understand I sound confusing. I figured it out. This will reset the permissions not the ownership. I apologies for being annoying. I'm just trying to lean as much as possible. I'm in interested in this stuff. I'm highly grateful to you for helping me out. Thank you and God bless.
Credits to you for bringing this to my attention and the all the members who helped me out in my quest. I'm a hobbyist graphics designer, vectors, artworks, along with Windows themes. I've been messing with system files without any concern for security or stability up until now but not any more. Thanks to to the awesome guys here at MDL.
icacls will only reset permissions for inherited objects/containters if the parent object permissions are changed, i don't think it will restore them to Windows-default
@ceo54 You may need this. Take_Ownership_Advanced_Context_Menu.reg https://pastebin.com/abrLTCMN by @BAU
@Windows_Addict This is even better. This appears like a complete package with nothing left to do. Also includes in the package are entries to remove the entries from the context menus. Thank you for the help bud. This is very kind of you. Edit: Script gives me full control over the files/folders owned by SYSTEM but I couldn't "clear the gained access" that was the original question. There must be something I'm doing wrong.
@ceo54 in "Clear the gained access" option it restores the permission same as the default of general data files and folders because to restore the original values, a tool must have to store its permission to restore it later and that script doesn't do that work. Try NTFS Permissions Tools https://www.majorgeeks.com/files/details/ntfs_permissions_tools.html It provides the option to store files permission and you can restore it later. I've used it in the past for some time, worked okay.