Sending Shell Commands

This is a discussion on Sending Shell Commands within the C# Programming forums, part of the General Programming Boards category; I want to use C# to send a command to the shell. I dont want to open an external application ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    3

    Question Sending Shell Commands

    I want to use C# to send a command to the shell. I dont want to open an external application I just want to send a command such as the PAUSE command to the shell. It would be much appreciated if someone could tell me how to do this.

  2. #2
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    You need to look at the System.Diagnostics.Process class..

    You can do something like the following to execute a command in the shell. But I don't think this is going to work for the pause command as it is not a file as such. What are you trying to acheive, perhaps there is a better way of doing this?

    Code:
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.EnableRaisingEvents=false;
    proc.StartInfo.FileName="calc";
    proc.Start();

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    3
    Well I guess that I could just use Console.ReadLine(); to wait for the user to press enter. I could also write my own code to have the computer wait for the user to press any key so I guess I'll do one of those two things. I also wanted to use it to add some console arguments to an application I wanted to run but I was reading on MSDN and I figured out how to do that with the arguments property of the StartInfo class.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows shell commands - multiple files
    By Magos in forum Tech Board
    Replies: 3
    Last Post: 02-28-2006, 12:56 AM
  2. Shell Commands
    By Frantic- in forum C++ Programming
    Replies: 6
    Last Post: 11-12-2005, 10:35 AM
  3. Program to execute shell commands.
    By LiquidLithium in forum C++ Programming
    Replies: 6
    Last Post: 09-01-2004, 12:22 PM
  4. Sending commands over IDE
    By Coherent in forum Windows Programming
    Replies: 0
    Last Post: 10-07-2003, 11:12 AM
  5. Sending commands to port
    By Neha in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 02-28-2002, 01:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21