2012年5月14日 星期一

run shell command and then display the result on web through asp.net via vb.net


       Dim psi As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo

        psi.FileName = "ipconfig.exe"
        psi.Arguments = " /all"
        psi.UseShellExecute = False
        psi.RedirectStandardInput = True
        psi.RedirectStandardOutput = True

        Dim ps As System.Diagnostics.Process = New System.Diagnostics.Process
        ps.StartInfo = psi
        ps.Start()
        Dim sr As StreamReader = ps.StandardOutput
        Dim aa As String
        While (Not sr.EndOfStream)
            aa = sr.ReadLine
            Response.Write(aa)
            Response.Write("
")
        End While
       ps.Dispose()

沒有留言: