我创建一个程序,当我复制“ 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);
}
}
答案 0 :(得分:1)
要使用url
工具查看WiFi配置文件密码,必须在管理权限下运行它。
使用此命令:
netsh
添加
netsh wlan show profile <SSID_name> key=clear
进入您的流程启动配置。
答案 1 :(得分:0)
Process processWifi = new Process();
processWifi.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processWifi.StartInfo.FileName = "netsh";
processWifi.StartInfo.Arguments = "wlan show profile";
processWifi.StartInfo.UseShellExecute = false;
processWifi.StartInfo.RedirectStandardError = true;
processWifi.StartInfo.RedirectStandardInput = true;
processWifi.StartInfo.RedirectStandardOutput = true;
processWifi.StartInfo.CreateNoWindow = true;
processWifi.Start();
string output = processWifi.StandardOutput.ReadToEnd();
string err = processWifi.StandardError.ReadToEnd();
processWifi.WaitForExit();
return output;