Need help starting CMD commands in C#...

Discussion in 'Programming General' started by Cymru, Oct 18, 2008.

Need help starting CMD commands in C#...
  1. Unread #1 - Oct 18, 2008 at 5:56 PM
  2. Cymru
    Joined:
    Jan 22, 2007
    Posts:
    693
    Referrals:
    0
    Sythe Gold:
    0

    Cymru Apprentice
    Banned

    Need help starting CMD commands in C#...

    I've been looking for a guide or something that will show me the steps to getting this to work.

    I know there is something to do with System.Diagnostics.processstartifo
    or something...

    If someone can just show me a way to start a simple command like dir by pressing a button on my form. Thanks.

    EDIT: I found out how to do it:

    you needed to have startinfo.FileName for the cmd and startinfo.Arguments for the commands.
     
  3. Unread #2 - Oct 18, 2008 at 9:19 PM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Need help starting CMD commands in C#...

    An easier way would be:

    Code:
    System.Diagnostics.Process.Start("<command>");
     
  5. Unread #3 - Oct 21, 2008 at 8:36 PM
  6. Cymru
    Joined:
    Jan 22, 2007
    Posts:
    693
    Referrals:
    0
    Sythe Gold:
    0

    Cymru Apprentice
    Banned

    Need help starting CMD commands in C#...

    Yes, but I think that has a different affect (possibly). Can you still give arguments for it?

    And it seems to be the same length code, so it doesn't matter.
     
  7. Unread #4 - Oct 22, 2008 at 3:10 AM
  8. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Need help starting CMD commands in C#...

    Command line arguments simply follow after the command in question.

    e.g.

    Code:
    Process.Start("notepad C:\test.txt");
     
  9. Unread #5 - Oct 23, 2008 at 10:20 PM
  10. Cymru
    Joined:
    Jan 22, 2007
    Posts:
    693
    Referrals:
    0
    Sythe Gold:
    0

    Cymru Apprentice
    Banned

    Need help starting CMD commands in C#...

    Not for cmd though.
    "cmd.exe dir" doesn't work.
     
  11. Unread #6 - Nov 13, 2008 at 4:19 AM
  12. x&#8313;
    Referrals:
    1

    x&#8313; Guest

    Need help starting CMD commands in C#...

    you can't execute commands like 'dir' using that method. Those are built into cmd.exe.
     
< Need help in computer science course... | help >

Users viewing this thread
1 guest


 
 
Adblock breaks this site