473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 18583
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.