Dha*_*ree 5 permissions ownership file-permissions windows-10
- 取得 Windows 文件夹及其内容的所有权
- 做出改变
- 归还原所有权
- 了解流程
- 在 Windows 10 环境中使用 Icacls 和删除
Before using takeown and icacls commands because of the sensitive nature of windows folders, I would like to know and understand what changes to permissions will take place, so that they can be reset to their original position. As one article I read said “Be careful, taking the ownership of system folders you may break your operating systems.” Though I don’t think I will in this case, as I plan to use this on more than one computer, it would be good to know what is going on, so that the correct commands are used.
这是我目前的潜在脚本:
takeown /f C:\Windows\Web
takeown /f C:\Windows\Web\*.* /R
…changes to default image cache here…
icacls C:\Windows\Web\*.* /reset /T /C
icacls c:\Windows\Web\*.* /setowner " Web NT SERVICE\TrustedInstaller" /T /C"
icacls c:\Windows\Web /setowner " Web NT SERVICE\TrustedInstaller" /T /C"
Run Code Online (Sandbox Code Playgroud)
目前的理解:
A) takeown /f C:\Windows\Web (Take ownership of directory)
A) takeown /f C:\Windows\Web\*.* /R
(Take ownership of all files and subdirectories)
[[B is an alternative for A]]
B) takeown /f C:\Windows\Web /R /d Y
(?? recursively take ownership of all files and folders)
C) icacls C:\Windows\Web\*.* /T /C /reset
(?? this resets security permissions to default for all the folders,
files and subfolders)
D) icacls c:\Windows\Web\*.* /setowner " Web NT SERVICE\TrustedInstaller" /T /C"
(This resets the owner of the folder contents see last script box)
E) icacls c:\Windows\Web /setowner " Web NT SERVICE\TrustedInstaller" /T /C"
Set owner of folder back to original
Run Code Online (Sandbox Code Playgroud)
当前文件夹权限为:
COMMAND PROMPT - ADMINISTRATOR
C:\Windows>icacls "C:\Windows\Web"
C:\Windows\Web NT SERVICE\TrustedInstaller:(F)
NT SERVICE\TrustedInstaller:(CI)(IO)(F)
NT AUTHORITY\SYSTEM:(M)
NT AUTHORITY\SYSTEM:(OI)(CI)(IO)(F)
BUILTIN\Administrators:(M)
BUILTIN\Administrators:(OI)(CI)(IO)(F)
BUILTIN\Users:(RX)
BUILTIN\Users:(OI)(CI)(IO)(GR,GE)
CREATOR OWNER:(OI)(CI)(IO)(F)
APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(RX)
APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(OI)(CI)(IO)(GR,GE)
APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APP PACKAGES:(RX)
APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APP PACKAGES:(OI)(CI)(IO)(GR,GE)
Run Code Online (Sandbox Code Playgroud)
读:
您不需要分别执行目录和内容。您也不想重置权限。
简单的方法
从管理员命令提示符:
takeown /f C:\Windows\Web /r
%USERDOMAIN%\%USERNAME%会自动替换为您的用户 - 您无需在此处替换任何内容。icacls C:\Windows\Web /grant "%USERDOMAIN%\%USERNAME%":(F) /t
进行更改
改回所有权。
icacls c:\Windows\Web /setowner "NT SERVICE\TrustedInstaller" /t
icacls C:\Windows\Web /remove:g "%USERDOMAIN%\%USERNAME%":(F) /t
替代方法
另一种方法是保存和恢复 ACL,这将涵盖以下情况:您的用户已授予目录中某些您不想删除的对象的权限/remove:g。
icacls C:\Windows\Web /save "C:\Web.acl" /t
takeown /f C:\Windows\Web /r
icacls C:\Windows\Web /grant "%USERDOMAIN%\%USERNAME%":(F) /t
进行更改
改回所有权。
icacls c:\Windows\Web /setowner "NT SERVICE\TrustedInstaller" /t
C:\Windows不是C:\Windows\Web.icacls C:\Windows /restore "C:\Web.acl"
| 归档时间: |
|
| 查看次数: |
7960 次 |
| 最近记录: |