'problems running vssadmin from c#

I am executing the following code from C#

Process process = new Process
        {
            StartInfo = new ProcessStartInfo("cmd.exe", "/c vssadmin resize shadowstorage /for=C: /on=C: /maxsize=10%")
            {
                WorkingDirectory = Environment.SystemDirectory,
                CreateNoWindow = true,
                UseShellExecute = false,
                RedirectStandardError = true,
                RedirectStandardOutput = true
            }
        };
        
        process.OutputDataReceived += (object _sender, DataReceivedEventArgs _e) => Console.WriteLine("output :: " + _e.Data);

        process.ErrorDataReceived += (object _sender, DataReceivedEventArgs _e) => Console.WriteLine("error :: " + _e.Data);

        process.Start();
        process.BeginOutputReadLine();
        process.BeginErrorReadLine();
        process.WaitForExit();

        Console.WriteLine("ExitCode: {0}", process.ExitCode);
        process.Close();

and it shows me the following error

"vssadmin" is not recognized as an internal or external command

but if I execute that line from the command console it works correctly

enter image description here

How can I execute that code from c#? Regards!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source