I have a System.Diagnostics.Process that I would like to call upon a shell application (ipconfig). I want to then gather the ipconfig information in a variable. Is there a way to do this? Here is what I have so far:
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 Class
The error I am getting is this: System.InvalidOperationException:
StandardOut has not been redirected. at System.Diagnostics.Process.get_StandardOutput() at Machine.MacAddress(String ipAddress) Does anyone have a clue?
Jason N. Gaylord
ASPInsider and Microsoft MVP
http://jasongaylord.com
j_gaylord
Contributor
3444 Points
731 Posts
ASPInsiders
MVP
System.Diagnostics.Process Question
Mar 05, 2003 04:51 PM|LINK
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 ClassThe error I am getting is this: System.InvalidOperationException: StandardOut has not been redirected. at System.Diagnostics.Process.get_StandardOutput() at Machine.MacAddress(String ipAddress) Does anyone have a clue?ASPInsider and Microsoft MVP
http://jasongaylord.com
j_gaylord
Contributor
3444 Points
731 Posts
ASPInsiders
MVP
Re: System.Diagnostics.Process Question
Mar 05, 2003 05:20 PM|LINK
ASPInsider and Microsoft MVP
http://jasongaylord.com
Koben
Member
20 Points
4 Posts
Re: System.Diagnostics.Process Question
Aug 27, 2003 05:30 PM|LINK