在dos下运行程序并得到运行结果

 'Imports System.Diagnostics

        Dim p As New Process

        p.StartInfo.FileName = "cmd.exe"

        p.StartInfo.UseShellExecute = False

        p.StartInfo.RedirectStandardInput = True

        p.StartInfo.RedirectStandardOutput = True

        p.StartInfo.RedirectStandardError = True

        p.StartInfo.CreateNoWindow = True '不想看见那个黑黑的dos窗口

        p.Start()

        p.StandardInput.WriteLine("pint -n 1 192.168.10.100") '不小心把ping写成pint了

        p.StandardInput.WriteLine("ping -n 1 192.168.10.100")

        p.StandardInput.WriteLine("exit")

        Dim strRet As String

        strRet = p.StandardOutput.ReadToEnd()

        MsgBox(strRet)

        strRet = p.StandardError.ReadToEnd()

        MsgBox(strRet)

posted @ 2008-01-28 23:11  HappyQQ  阅读(716)  评论(1编辑  收藏  举报