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

Li, Andrew (Ming) 1 Reputation point
2021-03-17T06:56:28.887+00:00

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://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/apply-a-basic-audit-policy-on-a-file-or-folder

Thanks
Andrew

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

1 answer

Sort by: Most helpful
  1. Sheng Jiang 蒋晟 206 Reputation points
    2021-03-18T20:10:21.157+00:00

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

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.