Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ipconfig,Ping,nsloookup programs

Posted on 2003-11-21
3
Medium Priority
?
961 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 300 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 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