0

I’m suffering with a problem for a month, I want to run the cmd command "sfc / scannow", before that I tried to read the result of this command via StandartOutput, but it’s not working with this command, I had an idea to press the button to call the console with this command and watch the result is in cmd, but I have a problem again, I just have cmd and everything is open, the command is not executed.I need to run the sfc / scannow command and see the process and the result of the check, in any way, but using C # (the project was created on win.forms)Please, help me

Also work with other cmd commands, I read through StandartOutput, but it doesn’t work with this command


string strCmdText;
            strCmdText = "sfc/scannow";
            Process cmdSFC = Process.Start(new ProcessStartInfo
            {
                UseShellExecute = true,
                WorkingDirectory = @"C:\Windows\System32",
                FileName = @"C:\Windows\System32\cmd.exe",
                Arguments = "/c " + strCmdText,

            });
  cmdSFC.WaitForExit();

1 Answers1

0

Set UseShellExecute to false. As described in MSDN:

Setting this property to false enables you to redirect input, output, and error streams.

montonero
  • 1,363
  • 10
  • 16