0

I am having an issue regarding the process class in c#, specifically when trying to start the command prompt. What occurs is that an infinite amount of cmd windows open, then infinitely close as if caught in a loop, despite the fact that there is none; it literally freezes my computer when run. This however, ONLY occurs on my 64 bit vista; the code (which I will post shortly) works totally fine on my 32bit lenovo thinkpad, and I can't figure out why. Note that the standard output lines are not what is causing the issue; I tried removing them, with no luck. Any ideas would be much appreciated.

using System;
using System.Windows.Forms;
using System.Diagnostics;

public class BuildByteArray
{

    public static void Main()
    {


        Process process = new Process();
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardOutput = true;
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        startInfo.FileName = "cmd.exe";
        startInfo.Arguments = "/c ipconfig";
        MessageBox.Show("");
        process.StartInfo = startInfo;

        process.Start();
        string output = process.StandardOutput.ReadToEnd();
        MessageBox.Show(output);
        process.WaitForExit();

    }
}
Ari
  • 3,489
  • 5
  • 26
  • 47
  • Is your application compiled as AnyCPU...try compiling as x86. If it's already 32bit/x86, then maybe the Wow64 redirection is getting in the way. Suggestion on how to stop that here: http://stackoverflow.com/questions/2003573/how-to-start-a-64-bit-process-from-a-32-bit-process – Colin Smith Aug 03 '12 at 11:48
  • Could also try...CreateNoWindow = true on the StartInfo. – Colin Smith Aug 03 '12 at 11:56

0 Answers0