I\'ve been trying to solve the problem that Chris Iverson was having in this other Stackoverflow question.
I want to launch SFC (the System File
With all the help here I ended up with this and it worked fine on 8.1 x64. Thank you all very much!
...
using System.Diagnostics;
...
private void button4_Click(object sender, EventArgs e)
{
string docs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string snat = Environment.GetEnvironmentVariable("windir") + @"\sysnative\sfc.exe";
Process a = new Process();
a.StartInfo.FileName = snat;
a.StartInfo.Arguments = "/SCANNOW";
a.StartInfo.UseShellExecute = false;
a.StartInfo.RedirectStandardOutput = true;
a.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
a.StartInfo.CreateNoWindow = true;
a.Start();
string output = a.StandardOutput.ReadToEnd();
a.WaitForExit();
using (StreamWriter outfile = new StreamWriter(docs + @"\Testoutput.txt"))
{
outfile.Write(output);
}
MessageBox.Show("DONE!");
}