• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1487
  • Last Modified:

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
0
InsProf
Asked:
InsProf
1 Solution
 
Reza RadCommented:
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
 
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
 
InsProfAuthor Commented:
I added the /C to the arguments list and it worked.
 
Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now