2014-11-20 45 views
1

所以,我想要做的是使命令提示符打开按钮设置周长按下。这是我到目前为止有:参数和命令提示符

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

我遇到的问题是“平”和“-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. 

回答

2

有哪些&做字符串中?这是用于启动新进程的命令提示符命令。

例如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)) 
+1

这是有效的,但事情是我绝对需要脚本中的-l。 – TheCloud 2014-11-21 00:00:30

+0

,但是如果你放入'-l',它只是给出'必须为选项-l提供值。如果你有一定的价值,就把它放在字符串中,例如'“/ k ping -l 1000 -t {0}”' – TessellatingHeckler 2014-11-21 00:23:32