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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Using the Command Prompt in C# Win App

Using the Command Prompt in C# Win App

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
2 Posts 2 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.
  • C Offline
    C Offline
    chubbysilk
    wrote on last edited by
    #1

    Hello, I am writing a C# windows application. I would like to open a command prompt and execute a few lines of code. I am able to open the command prompt using the following code: System.Diagnostics.Process.Start("cmd.exe"); But I don't know how to actually write a command to the prompt once it is open. Can anyone help me out? Thanks, RC

    H 1 Reply Last reply
    0
    • C chubbysilk

      Hello, I am writing a C# windows application. I would like to open a command prompt and execute a few lines of code. I am able to open the command prompt using the following code: System.Diagnostics.Process.Start("cmd.exe"); But I don't know how to actually write a command to the prompt once it is open. Can anyone help me out? Thanks, RC

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      If you read the documentation for the Process.Start method, the following should be evident:

      Process.Start("cmd.exe", "/c someapp.exe");

      Other documentation for members of the Process class show examples of how to capture console output. Please note that if an application uses the console subsystem, you don't actually need to start cmd.exe (the command environment for Windows NT - command.com for Windows (9x/ME)). A console program in Windows NT (NT4, 2000, XP, and 2003, plus all future Windows platforms) will automatically start in a console window, which you can suppress by using the Process.Start(ProcessStartInfo) method override and set ProcessStartInfo.CreateNoWindow to true. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

      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