title: How do I get the "ERRORLEVEL" variable set by a command line scanner in my C# program?
body: <p>In my website I want to virus-check any uploaded files before saving them into my database. So I save the file to the local directory then kick-off a command-line scanner process from inside my C# program. Here is the code I use:</p>
  
  <pre><code>  string pathToScannerProgram = Path.Combine(virusCheckFolder, "scan.exe");
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = pathToScannerProgram;
    startInfo.Arguments = String.Format("\"{0}\" /FAM /DAM", fileToScanPath);
    startInfo.RedirectStandardOutput = true;
    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    startInfo.UseShellExecute = false;
  
    using (Process process = new Process())
    {
      process.StartInfo = startInfo;
      process.Start();
      string output = process.StandardOutput.ReadToEnd();
      string errorLevel = Environment.GetEnvironmentVariable("ERRORLEVEL");
      process.WaitForExit();
    }
  </code></pre>
  
  <p>My problem is that Environment.GetEnvironmentVariable("ERRORLEVEL") is always returning null. It should be returning a number. So how do I get the "ERRORLEVEL" set by the command line scanner in my C# program?</p>