question

LiAndrewMing-8013 avatar image
0 Votes"
LiAndrewMing-8013 asked jiangshengvc edited

How to enable the auditing function of files programmatically or command line

I want to enable the audit policy on a file on the local computer of Win10. I hope this can be done by writing code or command line. I hope to get any help.

The following link describes the use of graphical operations to enable auditing. This is not what I want. I hope to complete similar functions by writing code or command lines.
https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/apply-a-basic-audit-policy-on-a-file-or-folder


Thanks
Andrew

dotnet-csharpc++
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @LiAndrewMing-8013,

Thank you for posting here.

Based on the description above, I understand you want to enable audit policy on a file or folder via Code or command instead of via GUI.

I will edit the tags and add the code language, so that the engineer from code team will helpf you further.

Thank you for your understanding and support.


Best Regards,
Daisy Zhou

0 Votes 0 ·

1 Answer

jiangshengvc avatar image
0 Votes"
jiangshengvc answered jiangshengvc edited

you can use auditpol /resourceSACL
or if you prefer C++, check Modifying the ACLs of an Object in C++


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.