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

it2025-03-24  19

'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)

转载于:https://www.cnblogs.com/HappyQQ/archive/2008/01/28/1056818.html

最新回复(0)