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

Li, Andrew (Ming) 1 Reputation point

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.


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.
10,641 questions
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.
3,633 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sheng Jiang 蒋晟 206 Reputation points

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

    0 comments No comments