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. Command Line

Command Line

Scheduled Pinned Locked Moved C#
csharp
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.
  • S Offline
    S Offline
    SJR_1
    wrote on last edited by
    #1

    I'm trying to send commands from my C# project to the command line. The cmd is opening but the arguments are not being passed. Here is my code: System.Diagnostics.ProcessStartInfo psi = null; System.Diagnostics.Process proc = null; psi = new System.Diagnostics.ProcessStartInfo("cmd"); proc = new System.Diagnostics.Process(); proc.StartInfo = psi; System.Diagnostics.Process.Start(psi); psi.Arguments = @"ping dev12"; Application.DoEvents(); System.Diagnostics.Process.Start(psi); proc.WaitForExit(); Thanks.

    D 1 Reply Last reply
    0
    • S SJR_1

      I'm trying to send commands from my C# project to the command line. The cmd is opening but the arguments are not being passed. Here is my code: System.Diagnostics.ProcessStartInfo psi = null; System.Diagnostics.Process proc = null; psi = new System.Diagnostics.ProcessStartInfo("cmd"); proc = new System.Diagnostics.Process(); proc.StartInfo = psi; System.Diagnostics.Process.Start(psi); psi.Arguments = @"ping dev12"; Application.DoEvents(); System.Diagnostics.Process.Start(psi); proc.WaitForExit(); Thanks.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      The argument ARE being passed. You're just not supplying the correct arguments to CMD. The command line your passing in is this:

      cmd ping dev12
      

      Try typing that in a Start/Run box and watch what happens. What you should be passing in is:

      cmd /c ping dev12
      

      The "/C" tells CMD to execute the following string and a command, then terminate when that command is done. "/K" will tell CMD to remain open after the command it execute returns. All you have to do to find this out is type "CMD /?" at a command prompt. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      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