
Windows ディレクトリ ( explorer.exe
、など) 内の実行可能ファイルの所有権を変更した後、を使用するregedit.exe
ように戻すことができないようです。GUI 方式 (TrustedInstaller
icacls.exe
プロパティ → セキュリティ → 詳細設定 → 所有者) は問題なく動作します。
Windows上の他のファイルに対しても同じことを行うと、ない実行可能ファイルで、正常に動作します。セーフモードで同じことを試しましたが、うまくいきませんでした。
私が使用している 2 つの基本コマンドは次のとおりです。
takeown /F C:\Windows\explorer.exe /A
icacls C:\Windows\explorer.exe /setowner "NT SERVICE\TrustedInstaller"
編集: 「アクセスが拒否されました」というエラーが表示されることをお伝えするのを忘れました。
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
答え1
タイトルには「TrustedInstaller を復元する」と書かれています。
不足している部分があるようです。追加された Administrators グループの権限を削除します。
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
答え2
このコマンドは、Administrators グループに完全な権限を付与した後にのみ機能します。
icacls c:\Windows\explorer.exe /grant Administrators:f
何らかの理由で、「変更」を許可しても十分ではないようです。
答え3
問題は、あなたが回答で発見したように、ファイルの所有者を設定するには特別な権限、具体的には「所有権の取得」が必要であることです。ACLエディタGUIがとにかく所有者を設定できる理由は、SeTakeOwnershipPrivilege
特権これにより、そのアクセス チェックを上書きできます。管理者として実行されているプログラムにはこの権限がありますが、使用する前に明示的に有効にする必要があり、どうやらそうicacls
していないようです。
便利なことに、プロセスはデフォルトで親の権限を継承するので、を呼び出すコマンドプロンプトでその権限を有効にするとicacls
、ユーティリティでも権限が有効になり、所有者を設定できるようになります。私のオープンソースユーティリティを使用できます。スプリントDLLSprintDLL の親プロセス (コマンド プロンプト) で権限を有効にするために適切な Win32 関数を呼び出します。
SprintDLL call kernel32.dll!OpenProcess /return native /into prochandle (int 0x400, int 0, slotdata parentpid); newslot native token; call advapi32.dll!OpenProcessToken /return int (slotdata prochandle, int 0x20, slotptr token); newslot block luid = int 0, int 0; call advapi32.dll!LookupPrivilegeValueW /return int (nullptr, lpwstr "SeTakeOwnershipPrivilege", slotptr luid); newslot block privs = int 1, slotdata luid, int 2; call advapi32.dll!AdjustTokenPrivileges /return int (slotdata token, int 0, slotptr privs, slotsize privs as int, nullptr, nullptr)
正常に動作した場合、出力には、呼び出された 3 つの関数すべてが 1 を返したことが表示されます。その後、最初に試行したとおりに使用できるようになりますicacls
。
答え4
これは、64 ビット システム (および私の問題) では機能しました...
icacls c:\Windows\SysWOW64\usercpl.dll /grant Administrators:f
icacls "C:\Windows\SysWOW64\usercpl.dll" /setowner "NT SERVICE\TrustedInstaller"
/setowner - 新しい所有者