Link to home
Start Free TrialLog in
Avatar of InsProf
InsProf

asked on

How to export ipconfig results to a text file via VB.net

Hi,
I am trying to programatically(VB.net) create a file with all ipconfig data, just like the cmd command ipconfig /all > <outputPath>
I used this code, but no file has been created:  
  With pStart.StartInfo
                .UseShellExecute = True
                 .FileName = "cmd.exe"
                .Arguments = "ipconfig.exe /ALL >" + outputPath
            End With

            ' Execute the process and wait for it to exit
            If pStart.Start() Then
                pStart.WaitForExit()
            End If

Any suggestions?

Thanks
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

don't use cmd.exe , use ipconfig.exe directly
and then after WaitForExit() use :
string result=pStart.StandardOutput.ReadToEnd();

then you can write this string to file

let me know if  you had problem on it
ASKER CERTIFIED SOLUTION
Avatar of oferam
oferam
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of InsProf
InsProf

ASKER

I added the /C to the arguments list and it worked.
 
Thanks