【发布时间】:2019-09-23 15:28:04
【问题描述】:
我创建了一个程序,当我复制“WiFi 状态”时,会显示一条带有 SSID 的 Windows 消息并显示单一强度。现在我还想要获取 WiFi 密码的选项,但我不知道该怎么做。因为如果我执行命令wlan show profile "+ s1 +" key = clear ",当我执行命令时他也无法显示密码string s3 = s.Substring (s.IndexOf ("Key Content"));有人可以帮助我
这是我的代码:
if (clipboardText == "wifi status")
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = "netsh.exe";
p.StartInfo.Arguments = "wlan show interfaces";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
string s = p.StandardOutput.ReadToEnd();
string s1 = s.Substring(s.IndexOf("SSID"));
s1 = s1.Substring(s1.IndexOf(":"));
s1 = s1.Substring(2, s1.IndexOf("\n")).Trim();
string s2 = s.Substring(s.IndexOf("Signal"));
s2 = s2.Substring(s2.IndexOf(":"));
s2 = s2.Substring(2, s2.IndexOf("\n")).Trim();
{
notifyIcon1.Icon = SystemIcons.Exclamation;
notifyIcon1.BalloonTipTitle = "";
notifyIcon1.BalloonTipText = "WIFI verbonden met " + s1 + " " + "Signaal sterkte " + s2;
notifyIcon1.BalloonTipIcon = ToolTipIcon.Error;
notifyIcon1.ShowBalloonTip(1000);
}
}
【问题讨论】:
-
据我所知,在 C# 中没有办法做到这一点。但我确实找到了this,这可能会有所帮助。如果它不起作用 - 尝试以管理员身份运行它。
-
这令人困惑。您正在调用
netsh wlan show interfaces,它向您显示网络硬件接口,而不是存储的 WiFi 设置。如果你想要netsh wlan show profile SSID_name key=clear的输出,那么你应该调用它..? -
我的电脑找不到那个命令
标签: c# networking wifi