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

C#
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.
10,641 questions
C++
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.
3,633 questions
{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