
現在、実行可能ファイルの「認証済みユーザー」権限を「ReadAndExecute」に設定するスクリプト ファイルがあります。これは Windows 10 では正常に動作しますが、Windows 7 では動作する必要がありますが、動作しません。
$file = (Resolve-Path 'c:\Dir\file.exe').Path;
$acl = (Get-Item $file).GetAccessControl('Access');
acl.SetAccessRuleProtection($True, $True);
$ar = New-Object System.Security.AccessControl.FileSystemAccessRule('Authenticated Users', 'Write', 'None', 'None', 'Allow');
$acl.RemoveAccessRuleAll($ar);
$ar = New-Object System.Security.AccessControl.FileSystemAccessRule('Authenticated Users', 'Modify', 'None', 'None', 'Allow');
$acl.RemoveAccessRuleAll($ar);
$ar = New-Object System.Security.AccessControl.FileSystemAccessRule('Authenticated Users', 'ReadAndExecute', 'None', 'None', 'Allow');
$acl.SetAccessRule($ar);
Set-ACL -Path $file -AclObject $acl;
これは実行されますが、認証されたユーザーの権限は設定されません。呼び出しを変更してパラメーターGetAccessControl
がない場合'Access'
、Win7 では次のエラーが発生します。
The security identifier is not allowed to be the owner of this object.
私がやろうとしていることを達成する方法はあるでしょうか?
追加要件:
- マシンに別のアプリをインストールすることはできません。Win 7のバニラインストールとみなします。
- 無人インストールスクリプトの一部であるため、非対話形式で実行する必要があります。