[英]Telnet from command line doesn't work
I want to open Telnet
session from command line via .NET. 我想通过.NET从命令行打开
Telnet
会话。 This command works fine manually: 此命令可以手动正常运行:
telnet towel.blinkenlights.nl
So i try to open it via .NET 所以我尝试通过.NET打开它
Process process = new Process();
process.StartInfo.FileName = @"C:\windows\system32\cmd.exe";
process.StartInfo.Arguments = "telnet towel.blinkenlights.nl";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
I am using Wireshark
to check if this start the traffic and here it seems that nothing happen and i cannot see any Telnet
traffic. 我正在使用
Wireshark
检查这是否启动了流量,并且在这里似乎什么也没有发生,并且我看不到任何Telnet
流量。
If you use ProcessWindowStyle.Normal
instead you would see you are not actually executing telnet. 如果改用
ProcessWindowStyle.Normal
,则会看到您实际上并未在执行telnet。 You must add the "/C" parameter if you want the CMD window to close after finishing or "/K" if you want it to remain open. 如果要在完成后关闭CMD窗口,则必须添加“ / C”参数;如果要使其保持打开状态,则必须添加“ / K”参数。
Process process = new Process();
process.StartInfo.FileName = @"C:\windows\system32\cmd.exe";
process.StartInfo.Arguments = "/k telnet towel.blinkenlights.nl";
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
process.Start();
process.WaitForExit();
After you get the behavior you want, then of course switch back to Hidden
. 获得所需的行为后,当然可以切换回
Hidden
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.