Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to write the command I wrote to cmd with c # and write the same results as code.
How do I convert cmd to c #?

For example:

cmd command is: ipconfig /all

I want to this command convert to c# code.How to convert cmd command to c# code.

What I have tried:

I don't write.Because I dont know cmd command convert to c#
Posted
Updated 12-Oct-19 23:27pm

1 solution

There are two ways to do it:
1) Run "ipconfig /all" in a process, capture the output and parse it to obtain the bite you want: Process.StandardOutput Property (System.Diagnostics) | Microsoft Docs[^]
2) You could use a combination of the System.Net.NetworkInformation Namespace | Microsoft Docs[^] classes and WMI to fetch just the information you are interested in directly within your app: Connecting to WMI Remotely with C# - Windows applications | Microsoft Docs[^]

Since we have no idea what you are trying to do, or your skill level in C# we can;t help you much more at this stage.
Start reading the links above, work out what exactly you are trying to do with the information you can collect, and give it a try.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900