参数和命令提示符

时间:2014-11-20 23:29:19

标签: vb.net command-line

所以,我要做的是按下按钮并按下设置周边打开命令提示符。这就是我到目前为止所做的:

Public ReadOnly Property TheIP() As String
    Get

        Return TextBox1.Text

    End Get
End Property

Process.Start("cmd", String.Format("/k {0} & {1} & {2}", "ping", TheIP, "-t", "-l"))

我遇到的问题是“ping”和“-t”没有正确执行。

我在命令提示符下收到以下消息:

'123.123.123.123' is not recognized as an internal or external command, operable program or batch file.

我也得到了

'-t' is not recognized as an internal or external command, operable program or batch file.

1 个答案:

答案 0 :(得分:2)

字符串中&做了什么?这是一个启动新进程的命令提示符命令。

e.g。 dir & dir将运行dir两次。因此,您的字符串正在运行ping,然后尝试将IP作为命令单独运行。

尝试:

Process.Start("cmd", String.Format("/k {0} {1} {2}", "ping", TheIP, "-t"))

(我把“-l”拿出去是因为你没有足够的字符串格式化地方来使用它,而且它本身也需要参数)

Process.Start("cmd", String.Format("/k ping -t {0}", TheIP))
相关问题