Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to start a process within the current command window?

How to start a process within the current command window?

Scheduled Pinned Locked Moved C#
questioncsharpsysadmintutorial
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Throckmorton
    wrote on last edited by
    #1

    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).

    T 1 Reply Last reply
    0
    • T Throckmorton

      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).

      T Offline
      T Offline
      Throckmorton
      wrote on last edited by
      #2

      Arg I figured it out. I used UseShellExecute = false and took out the CreateNoWindow = true.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups