将“TrustedInstaller”恢复为 Windows 文件夹中可执行文件的所有者

Bar*_*rCo 5 windows-7 command-line permissions

更改 Windows 目录(explorer.exeregedit.exe等)中可执行文件的所有权后,我似乎无法将其改回TrustedInstaller使用icacls.exe. 使用 GUI 方法(属性?安全?高级?所有者)可以正常工作。

对 Windows 下的任何其他文件(不是可执行文件)执行相同的操作,效果很好。在安全模式下试过同样的,没有运气。

这些是我正在使用的 2 个基本命令:

takeown /F C:\Windows\explorer.exe /A
icacls C:\Windows\explorer.exe /setowner "NT SERVICE\TrustedInstaller"
Run Code Online (Sandbox Code Playgroud)

编辑:忘记提及我收到的错误是“拒绝访问”。

C:\Windows\System32>takeown /F c:\Windows\explorer.exe /A  
SUCCESS: The file (or folder): "c:\Windows\explorer.exe" now owned by the administrators group.

C:\Windows\System32>icacls c:\Windows\explorer.exe /setowner "NT SERVICE\TrustedInstaller"  
c:\Windows\explorer.exe: Access is denied.  
Successfully processed 0 files; Failed processing 1 files  
Run Code Online (Sandbox Code Playgroud)

小智 8

所以标题说恢复 TrustedInstaller。

似乎有一个缺失的部分;删除添加的管理员组权限。

takeown /F "C:\Windows\regedit.exe" /A
/F - file to become owner of
/A - means it will set the users group (ie. Administrators, not userxyz)

icacls "C:\Windows\regedit.exe" /grant Administrators:F
/grant - will add permissions
:F - Full Control

icacls "C:\Windows\regedit.exe" /setowner "NT SERVICE\TrustedInstaller"
/setowner - new owner

icacls "C:\Windows\regedit.exe" /grant:r Administrators:RX
/grant:r - will set permissions (removing higher ones)
:RX - Read and Execute
Run Code Online (Sandbox Code Playgroud)

参考: https: //ss64.com/nt/icacls.html

  • 他正在将“管理员”的权利恢复到原来的权利。请记住,“管理员”之前已被分配了完全权限,这显然违背了 Microsoft 的意图,因此应在操作完成后恢复此权限。因此,我认为他的回答很有价值。 (2认同)

Bar*_*rCo 3

该命令只有在授予管理员组完全权限后才有效,即:

icacls c:\Windows\explorer.exe /grant Administrators:f  
Run Code Online (Sandbox Code Playgroud)

由于某种原因,即使授予“修改”似乎也还不够。