Solved

ipconfig,Ping,nsloookup programs

Posted on 2003-11-21
3
954 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

623 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