473,466 Members | 1,416 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Use Process.Start to execute Ipconfig

Hi,
In our application we need to use the Process command to execute and
retrieve the string that is returned when we execute IpConfig on the command
prompt.( yes have to use IPConfig)
the following code doesn't seem to work.
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments ="/c: /ipconfig";
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
return output;

Need help on this

Thanks

Manoj
Nov 17 '05 #1
2 18595
You don't need to execute cmd.exe, you can run ipconfig.exe directly.

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "ipconfig.exe";
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
return output;
If you can avoid calling ipconfig directly I would as the format of its
output and its parameters will vary from OS version to OS version. You
might be able to access the information you need via either WMI or
PInvoke. Check out http://www.pinvoke.net/ or search
http://www.CodeProject.com/ as there have been a lot of networking
related articles posted there.

Regards,

William D. Bartholomew
http://blog.bartholomew.id.au

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #2
Thanks William
Just passed the entire path along with the ipconfig and it worked
Thanks for the help
Manoj

"William Bartholomew" <william(at)bartholomew[dot]id{dot}au> wrote in
message news:#r**************@TK2MSFTNGP12.phx.gbl...
You don't need to execute cmd.exe, you can run ipconfig.exe directly.

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "ipconfig.exe";
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
return output;
If you can avoid calling ipconfig directly I would as the format of its
output and its parameters will vary from OS version to OS version. You
might be able to access the information you need via either WMI or
PInvoke. Check out http://www.pinvoke.net/ or search
http://www.CodeProject.com/ as there have been a lot of networking
related articles posted there.

Regards,

William D. Bartholomew
http://blog.bartholomew.id.au

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ilya Dubov | last post by:
I am starting "iexplore" process by executing Process.Start command. Every time I execute this command, it creates a new window. Can somebody tell me what can I do, so that the new window...
1
by: Marius Horak | last post by:
Hello, Program I want to execute is D:\Inetpub\ftproot\mtn\production\ToMin.EXE When I execute myExe = "D:\Inetpub\ftproot\mtn\production\ToMin.EXE"; Process.Start(myExe, "");
0
by: Sergistm | last post by:
Hello World, :D I have a problem that it is making me crazy, I hope you can help me. I'm trying to execute a .exe file with the Procces.Start, and there is no problem when the file is on my...
0
by: Daniel | last post by:
System.Diagnostics.Process.Start fails on windows server 2003 the process returns process.ExitCode == 0 but executing any process with System.Diagnostics.Process.Start on windows xp works fine....
1
by: Daniel | last post by:
what permissions does a windows service need to execute another process? System.Diagnostics.Process process = System.Diagnostics.Process.Start(info); just local administrator? any specific...
6
by: Leonel Galán | last post by:
When doing Process.Start(), I get "The parameter is invalid" Win32Exception when opening a particular exe. This exe works good in Windows (cmd.exe). The exe is "SPIM.exe" as the Simulator for...
4
by: =?Utf-8?B?VkIgSm9ubmll?= | last post by:
I am at my witless end here, please help! I have an ASP.Net aspx web page, hosted on Windows Server 2003, that receives a query string with the path to an autocad drawing file selected from a...
1
by: stemp1ar | last post by:
I am wondering if it possible to open a single process and run multiple commands on that process and check standard error and standard out after each command? Has anyone done something similar...
2
by: Kerem Gümrükcü | last post by:
Hi, i have a Process.Start call that fails with 267 Error Code if invoked with another user and password other than the applications user. It is a ordinary piece of code just create a Process...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.