我试图创建一个允许我ping ip地址并登录ssh部分的小程序。
我希望能够保持ping可变ip地址而不关闭其中任何一个。
我想对ssh部分做同样的事情。现在我必须关闭cmd,然后ping一个不同的地址。
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ip As String = TextBox1.Text
Dim Command As String
Command = "putty.exe" & " " & "-ssh" & " " & "user" & "@" & ip & " " & "port" & " " & "-pw" & " " & "Password"
Shell($"cmd /K{Command}", 1, True)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim textvar As String = TextBox2.Text
Dim Command As String
Command = "Ping" & " " & textvar & " " & "-t "
Shell("cmd /k" & Command, 1, True)
End Sub
End Class
答案 0 :(得分:0)
我无法解决您的问题,但可能会帮助您清理一下代码。
而不是使用
& " " &
为什么不把字符串放在一起。然后看起来像:
Command = "putty.exe -sh user@" & ip & " port -pw Password"
Shell($"cmd /K{Command}", 1, True)
它做的完全相同,但并没有接近尽可能多的字符,并且在我自己的拙见中更容易阅读。