打开CMD窗口并运行命令

时间:2013-08-07 15:19:04

标签: vbscript

以下VB脚本打开CMD窗口并执行ping到IP - 127.0.0.1

我不明白为什么CMD窗口的输出只包含ping的结果而不包括“ping 127.0.0.1”?

我的问题是什么需要在我的VB脚本中进行更改,以便从CMD窗口查看ping命令而不仅仅是ping结果?

我的VB脚本:

 Dim oShell
 Set oShell = WScript.CreateObject ("WScript.Shell")
 oShell.run "cmd /k CD C:\Program Files & ping 127.0.0.1   " ,1 , true

我从CMD看到的只是:( ping 127.0.0.1不是apears?)

Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Ping statistics for 127.0.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

1 个答案:

答案 0 :(得分:0)

“ping 127.0.0.1”是批处理文件命令。如果你点击开始按钮,输入“命令提示符”,打开命令提示符并输入该命令,然后你将得到一个输出的行。

Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL-128
Reply from 127.0.0.1: bytes=32 time<1ms TTL-128
Reply from 127.0.0.1: bytes=32 time<1ms TTL-128
Reply from 127.0.0.1: bytes=32 time<1ms TTL-128

Ping statistics for 127.0.0.1:
     Packets: Sent = 4, Received =  4, lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms