How to start a process within the current command window?
-
This might be a stupid question but I can't figure it out: I am writing a simple c# console app that calls another executable (usually a batch file but sometimes an exe). I want the other executable called to run in the same window that I ran the c# app. For instance, one of the executables I can call is an exe and it prints the build# to the screen. If I call it from the command prompt manually it runs in the same window: c:\>\\server\share\getversion build number: 3000 c:\> However in my C# app it always opens getversion.exe in a new window. How do I make it run in the current command window? I tried using ProcessStartInfo.CreateNoWindow = false but that doesn't work. if(Directory.Exists("\\\\server\\share\\")) { Process myProcess = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "\\\\server\\share\\getversion.exe"; myProcess.StartInfo = startInfo; myProcess.Start(); } When I run ConsoleApplication1.exe from a command prompt, it opens another command window, executes getversion.exe (which then closes immediately and you can't even see what it said).
-
This might be a stupid question but I can't figure it out: I am writing a simple c# console app that calls another executable (usually a batch file but sometimes an exe). I want the other executable called to run in the same window that I ran the c# app. For instance, one of the executables I can call is an exe and it prints the build# to the screen. If I call it from the command prompt manually it runs in the same window: c:\>\\server\share\getversion build number: 3000 c:\> However in my C# app it always opens getversion.exe in a new window. How do I make it run in the current command window? I tried using ProcessStartInfo.CreateNoWindow = false but that doesn't work. if(Directory.Exists("\\\\server\\share\\")) { Process myProcess = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "\\\\server\\share\\getversion.exe"; myProcess.StartInfo = startInfo; myProcess.Start(); } When I run ConsoleApplication1.exe from a command prompt, it opens another command window, executes getversion.exe (which then closes immediately and you can't even see what it said).
Arg I figured it out. I used UseShellExecute = false and took out the CreateNoWindow = true.