Issue executing command line command in .NET c#

0

Attempting to run ntdsutil from a C# executable and encountering an error. In case anyone is wondering, this is for a automated auditing process as part of a managed service provider - not trying to create a trojan/malware.

The command is: ntdsutil "ac i ntds" "ifm" "create full c:\audit" q q

This is Windows server specific, am running on Windows 2016.

I am using System.Diagnostics.Process and have tried various combinations of properties but getting same result. The following is an example, there is a standard output redirect so can see results of execution:

Process process = new System.Diagnostics.Process();
ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();

startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName = @"C:\Windows\System32\ntdsutil.exe";
startInfo.Arguments = "\"ac i ntds\" \"ifm\" \"create full c:\\audit\" q q";

//Set output of program to be written to process output stream
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError= true;

startInfo.UseShellExecute = false;
process.StartInfo = startInfo;
process.Start();

// Get program output
string strOutput = process.StandardOutput.ReadToEnd();

//Wait for process to finish
process.WaitForExit();
File.WriteAllText("out.txt", strOutput);

The output looks like this: C:\Windows\System32\ntdsutil.exe: ifm ifm: create full c:\audit error 0x80042302(A Volume Shadow Copy Service component encountered an unexpected error. Check the Application event log for more information.) ifm: q C:\Windows\System32\ntdsutil.exe: q

Have checked event logs as mention (nothing obvious) and done various searches on error but nothing useful appears. Running the command on command line works fine.

It is running a Administrator level user. Is it possible related to app.manifest priveleges?

Any help is appreciated.

c#
.net
asked on Stack Overflow Nov 1, 2020 by user3754525

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0