Windows で icacls を使用してアクセス許可を変更した後、ファイルにアクセスすると、断続的に「アクセスが拒否されました」というメッセージが表示されます。
詳細 : 管理者として実行されたスクリプトを参照してください。
import os
for x in range(50):
#this exe will check the existence of a file , is not present then copy the file and change the permission to ADMINISTRATOR/SYSTEM:F and BUILTIN/Users:(RX)
file = 'C:\\Program Files\\***\\test.exe'
retval = os.system('"' + file + '" -i')
print("retVal : %d" %retval)
#reset the permission of the same file and the parent folder
os.system("icacls C:\\ProgramData\\***\\ParentFolder /reset /T /Q /C")
os.system("icacls C:\\ProgramData\\***\\file.xml /grant *S-1-5-32-545:(W) /T /Q /C")