以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请教版主大一个小问题?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=147980)

--  作者:fangdejin
--  发布时间:2020/3/28 12:30:00
--  请教版主大一个小问题?
如何自动调用cmd来  telnet 47.94.26.205 80

这个不太会!ping值得已经可以了。

--  作者:有点蓝
--  发布时间:2020/3/28 14:40:00
--  
网上的方法,我电脑测试不行,直接打开cmd是可以的,您试试

Dim p As new Process()
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.Verb = "runas"
p.StartInfo.WorkingDirectory = SpecialFolder.system
\'p.StartInfo.Arguments = "/k telnet 127.0.0.1 80"
p.StartInfo.UseShellExecute = False \'关闭Shell的使用
p.StartInfo.RedirectStandardInput = True \'重定向标准输入
p.StartInfo.RedirectStandardOutput = True \'重定向标准输出
p.StartInfo.RedirectStandardError = True \'重定向错误输出
p.StartInfo.CreateNoWindow = True \'设置不显示窗口
p.Start()
p.StandardInput.WriteLine("telnet 127.0.0.1 80")
p.StandardInput.WriteLine("exit")
p.WaitForExit(5000)
Output.Show(2)
Dim s2 As String = p.StandardError.ReadToEnd()
Dim s As String = p.StandardOutput.ReadToEnd()
Output.Show(3)
Output.Show(s)
Output.Show(s2)
\'p.Close

--  作者:有点蓝
--  发布时间:2020/3/28 14:42:00
--  
再试试这个:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=62398&skin=0