#include <lsasecur.au3>
Local $hToken = _SeOpenProcessToken(-1)
_SeAdjustTokenPriv($hToken, $SE_RESTORE_PRIV)
_SeCloseHandle($hToken)
Local $pTrusteeOwner = _SeLookupAccountName("SYSTEM")
Local $pSecur = _SeInitSecurityDescriptor()
Local $sFilePath = @ScriptDir & "\test.x"
_SeSetSecurityDescriptorOwner($pSecur, $pTrusteeOwner)
If _SeSetFileSecurity($sFilePath, $SE_INFO_OWNER, $pSecur) Then
MsgBox(48, "OK", "Done.")
Else
MsgBox(48, "Error", _SeFormatMsg())
EndIf
_SeHeapFree($pSecur)
_SeHeapFree($pTrusteeOwner)
设置指定文件的所有者为SYSTEM用户,需要目标对象的DACL 允许WRITE_OWNER操作。 |