System Process and returning a value to a form

Below is a sample of a class I am trying to get to work. I would like to start a system process(ipconfig) and return the results.Imports System

Public Class Machine
    Dim myProcess As New System.Diagnostics.Process()

    Function IPConfig() As String
        Dim myConfig As String

        myProcess.StartInfo.RedirectStandardOutput = True
        myProcess.StartInfo.UseShellExecute = True
        myProcess.StartInfo.FileName = "ipconfig.exe"
        myProcess.StartInfo.Arguments = "/all"
        myConfig = myProcess.StandardOutput.ReadToEnd

        Return myConfig
    End Function

End ClassHowever, I keep getting this error:

<color="darkred">System.InvalidOperationException: StandardOut has not been redirected. at System.Diagnostics.Process.get_StandardOutput() at Machine.MacAddress(String ipAddress)</color>

Any ideas


Answer this question

System Process and returning a value to a form

  • Lordnikon981

    Now I have to figure out how to load the netbt driver. I keep getting a <color="darkred">Failed to access NetBT driver -- NetBT may not be loaded</color> error.
  • Ramesh Jha

    Found my answer: <a href="http://www.csharphelp.com/archives/archive210.html">http://www.csharphelp.com/archives/archive210.html</a>
  • Fahad Mukhtar

    It works fine on a Windows 2000 server but not on an XP Pro machine. Does anyone have any clue how to fix it on the XP machine
  • System Process and returning a value to a form