private static string GetPassword(string ssid) { string args = $@" wlan show profile name=""{ssid}"" key=""clear"""; string result = MyUtils.ExecCMD(args, "netsh"); Regex regex = new Regex(@"Key Content\s+:\s+([^\r\n]+)", RegexOptions.Multiline); MatchCollection matches = regex.Matches(result); string password = string.Empty; if (matches.Count > 0 && matches[0].Groups.Count > 1) { password = matches[0].Groups[1].Value; } return(password); }
private static IEnumerable <string> GetSSIDs() { string args = "wlan show profiles"; string result = MyUtils.ExecCMD(args, "netsh"); Regex regex = new Regex(@"\s+:\s+([^\r\n]+)", RegexOptions.Multiline); MatchCollection matches = regex.Matches(result); List <string> ssids = new List <string>(); for (int i = 0; i < matches.Count; i++) { if (matches[i].Groups.Count > 0 && !string.IsNullOrWhiteSpace(matches[i].Groups[1].Value)) { ssids.Add(matches[i].Groups[1].Value); } } return(ssids); }