您当前的位置:酷new网计算机应用应用技术 → 在线教程内容

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

  • 作者:佚名    来源:不详    发布时间:2008-1-29 10:54:29
  • 字体大小:
    '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)