Solved

ipconfig,Ping,nsloookup programs

Posted on 2003-11-21
3
947 Views
Last Modified: 2011-10-03
Does anyone know of ways to use these applications (ipconfig,ping,nslookup) within C#. I want to use these applications in the background and don't want the user to see usage of these applications. Thanks for any help.
0
Comment
Question by:andyk1
  • 2
3 Comments
 
LVL 22

Expert Comment

by:_TAD_
ID: 9799816


using System.Diagnostics;



            private void DOSCommand()
            {            
                  Process myDosCmd = null;
                  ProcessStartInfo qOptions = new ProcessStartInfo("cmd.exe", @"/C net send pc-02-49 This is a text Message");
                  qOptions.RedirectStandardOutput = false;  // set to "true" to enable logging
                  qOptions.UseShellExecute = true;  // set to true to make silent/background
                  qOptions.WindowStyle = ProcessWindowStyle.Hidden;

                  myDosCmd = Process.Start(qOptions);
                  myDosCmd.WaitForExit();
                  
                  //Logging commands
//                  string dosOut = DOS.StandardOutput.ReadToEnd();
//                  Console.Write(dosOut);
            }
0
 
LVL 22

Accepted Solution

by:
_TAD_ earned 75 total points
ID: 9799880


The above code is for the net send command but everything else works exactly the same.

Here is the code (altered slightly) to ping my own computer (although the window is not hidden like you would expect it to be)

:-(



            private void DOSCommand()
            {            
                  Process myDosCmd = null;
                  ProcessStartInfo qOptions = new ProcessStartInfo("cmd.exe", @"/C ping pc-02-49");
                  qOptions.WindowStyle = ProcessWindowStyle.Hidden;
                  qOptions.RedirectStandardOutput = true;  // set to "true" to enable logging
                  qOptions.UseShellExecute = false;  // set to true to make silent/background
                  
                  myDosCmd = Process.Start(qOptions);
                  myDosCmd.WaitForExit();
                  
                  //Logging commands
                  string dosOut = myDosCmd.StandardOutput.ReadToEnd();
                  Console.Write(dosOut);
            }



---Console---



Pinging PC-02-49.jsi.jc.com [10.1.63.10] with 32 bytes of data:



Reply from 10.1.63.10: bytes=32 time<1ms TTL=128

Reply from 10.1.63.10: bytes=32 time<1ms TTL=128

Reply from 10.1.63.10: bytes=32 time<1ms TTL=128

Reply from 10.1.63.10: bytes=32 time<1ms TTL=128



Ping statistics for 10.1.63.10:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 0ms, Average = 0ms

0
 
LVL 1

Expert Comment

by:nettnerd
ID: 9800185
If your interested in getting results within your program Check this link out.  Im sure there is code available for IpConfig / NSLookup Type Programs.
http://www.christopherlewis.com/Code/Ping/ping.cs.source
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now