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
InsProfAsked:
Who is Participating?
 
oferamCommented:
The first argument should be /C

Try use the full path of the IP Config utility - C:\windows\system32\ipconfig.exe
And the full path of the CMD.EXE - C:\windows\system32\cmd.exe


                 .FileName = "C:\\windows\\system32\\cmd.exe"
                .Arguments = "/C C:\\windows\\system32\\ipconfig.exe /ALL >" + outputPath

Good luck
0
 
Reza RadConsultant, TrainerCommented:
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
0
 
InsProfAuthor Commented:
I added the /C to the arguments list and it worked.
 
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.