I am trying to enable "Object Access->File System" and "Object Access->Registry" programmatically.
When I run auditpol /get /category:* command on command prompt, I can see that they are disabled:
I tried to use Powershell script and a function which written in .Net Framework 4.7.2 C#. Both are working fine on computers using Windows in English. Here is the function:
static void CallForAuditpol()
{
string command = $"/set /subcategory:\"File System\" /failure:enable /success:enable";
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "Auditpol",
Arguments = command,
Verb = "runas",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
};
process.StartInfo = startInfo;
try
{
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Console.WriteLine("Output:");
Console.WriteLine(output);
Console.WriteLine("Command ran successfully");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
But when I call this function on non-English environment, it expects me to write File System in native language. I have tried to run this code in Russian and when I wrote File System in Russian, it works as expected. Otherwise, it gives error as if parameters are wrong:
Is there any way to make this function independent from system language?