Skip to content

Newbie Q: How can I run dos commands in C# e.g. ipconfig

Loranga

Asked Sep 30, 2005, 12:04 AM EDT2 answers
Share
LinkedInX
Aloha,

I was using MS Visual studio net for the first time yesterday and made a simple calculator program in c#.
Now to my question: How can I run a dos command from C#? For example if I would to make a button that runs the command "ipconfig /all" or something like that.

 

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    using System.Diagnostics; string cmd = "net.exe"; string arg = "send user message"; Process.Start(cmd, arg); I hope it help you.
    0
  • 0
    C#
    try this
    using System.Diagnostics;
    Process p=new Process();
    p.StartInfo.FileName="cmd.exe";
    p.StartInfo.CreateNoWindow=true;
    p.StartInfo.UseShellExecute=false;
    p.StartInfo.Arguments="\k dir";//where dir can be any dos command
    p.Start();
    0