static void List(bool autoDelete) { var profiles = NetShWrapper.GetWifiProfiles(); var badWifiNetworkFound = false; foreach (var a in profiles) { var warning = NetShWrapper.IsOpenAndAutoWifiProfile(a) ? Resources.stringResources.WarningAutoConnect : String.Empty; Console.WriteLine("{0,-30} {1,10} {2,10} {3,30} ", a.Name, a.ConnectionMode, a.Authentication, warning); if (!String.IsNullOrWhiteSpace(warning)) { badWifiNetworkFound = true; } } if (badWifiNetworkFound) { if (!autoDelete) { Console.WriteLine(Resources.stringResources.DeleteAutoConnect); } if (autoDelete || Console.ReadLine().Trim().ToUpperInvariant().StartsWith(Resources.stringResources.AutoDeleteChar)) { foreach (var a in profiles.Where(NetShWrapper.IsOpenAndAutoWifiProfile)) { Console.WriteLine(NetShWrapper.DeleteWifiProfile(a.Name)); } } } else { Console.WriteLine(Resources.stringResources.NoWifi); } }
static void Main(string[] args) { var profiles = NetShWrapper.GetWifiProfiles(); bool sawBadWifi = false; foreach (var a in profiles) { string warning = NetShWrapper.IsOpenAndAutoWifiProfile(a) ? "Warning: AUTO connect to OPEN WiFi" : String.Empty; Console.WriteLine(String.Format("{0,-20} {1,10} {2,10} {3,30} ", a.Name, a.ConnectionMode, a.Authentication, warning)); if (!String.IsNullOrWhiteSpace(warning)) { sawBadWifi = true; } } if (sawBadWifi) { Console.WriteLine("\r\nDelete WiFi profiles that are OPEN *and* AUTO connect? [y/n]"); if (args[0].ToUpperInvariant() == "/DELETEAUTOOPEN" || Console.ReadLine().Trim().ToUpperInvariant()[0] == 'Y') { Console.WriteLine("in here"); foreach (var a in profiles.Where(a => NetShWrapper.IsOpenAndAutoWifiProfile(a))) { Console.WriteLine(NetShWrapper.DeleteWifiProfile(a)); } } } else { Console.WriteLine("\r\nNo WiFi profiles set to OPEN and AUTO connect were found. \r\nOption: Run with /deleteautoopen to auto delete."); } //Console.ReadKey(); }
static void List(bool autoDelete) { var profiles = NetShWrapper.GetWifiProfiles(); var badWifiNetworkFound = false; foreach (var a in profiles) { var warning = NetShWrapper.IsOpenAndAutoWifiProfile(a) ? "Warning: AUTO connect to OPEN WiFi" : String.Empty; Console.WriteLine("{0,-20} {1,10} {2,10} {3,30} ", a.Name, a.ConnectionMode, a.Authentication, warning); if (!String.IsNullOrWhiteSpace(warning)) { badWifiNetworkFound = true; } } if (badWifiNetworkFound) { if (!autoDelete) { Console.WriteLine("\r\nDelete WiFi profiles that are OPEN *and* AUTO connect? [y/n]"); } if (autoDelete || Console.ReadLine().Trim().ToUpperInvariant().StartsWith("Y")) { foreach (var a in profiles.Where(NetShWrapper.IsOpenAndAutoWifiProfile)) { Console.WriteLine(NetShWrapper.DeleteWifiProfile(a.Name)); } } } else { Console.WriteLine("\r\nNo WiFi profiles set to OPEN and AUTO connect were found. \r\nOption: Run with /deleteautoopen to auto delete."); } }
private void DeleteAutoOpen_Click(object sender, RoutedEventArgs e) { List <WifiProfile> wifiProfiles = NetShWrapper.GetWifiProfiles(); /* * Iterate over NetSh results to remove bad profiles. */ foreach (WifiProfile wifiProfile in wifiProfiles.Where(NetShWrapper.IsOpenAndAutoWifiProfile)) { NetShWrapper.DeleteWifiProfile(wifiProfile.Name); } }
private void ContextMenuStripOpening(object sender, CancelEventArgs e) { e.Cancel = false; notifyIcon.ContextMenuStrip.Items.Clear(); var profiles = NetShWrapper.GetWifiProfiles(); foreach (var profile in profiles) { notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem(profile.Name)); } notifyIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator()); notifyIcon.ContextMenuStrip.Items.Add(ToolStripMenuItemWithHandler("&Exit", ExitItemClick)); }
private void RefreshItemsSource() { WifiProfiles.Clear(); List <WifiProfile> wifiProfiles = NetShWrapper.GetWifiProfiles(); /* * Iterate over NetSh results to display them in the view. */ foreach (WifiProfile wifiProfile in wifiProfiles) { WifiProfiles.Add(wifiProfile); } listView.Items.Refresh(); }
private void button2_Click(object sender, EventArgs e) { //private void RefreshItemsSource() WifiProfiles.Clear(); List <WifiProfile> wifiProfiles = NetShWrapper.GetWifiProfiles(); /* * Iterate over NetSh results to display them in the view. */ foreach (WifiProfile wifiProfile in wifiProfiles) { WifiProfiles.Add(wifiProfile); } //listView.Items.Refresh(); label1.Text = "WifiProfiles.Count: " + WifiProfiles.Count() + "WifiProfiles.Count: " + WifiProfiles[0]; textBox1.Text = "hi"; }
static void List(bool autoDelete) { var profiles = NetShWrapper.GetWifiProfiles(); bool sawBadWifi = false; foreach (var a in profiles) { string warning = NetShWrapper.IsOpenAndAutoWifiProfile(a) ? "Warning: AUTO connect to OPEN WiFi" : String.Empty; // Console.WriteLine has a "formatting" overload Console.WriteLine("{0,-20} {1,10} {2,10} {3,30} ", a.Name, a.ConnectionMode, a.Authentication, warning); if (!String.IsNullOrWhiteSpace(warning)) { sawBadWifi = true; } } if (sawBadWifi) { if (!autoDelete) { Console.WriteLine("{0}Delete WiFi profiles that are OPEN *and* AUTO connect? [y/n]", Environment.NewLine); } if (autoDelete || Console.ReadLine().Trim().ToUpperInvariant().StartsWith("Y")) // Another String.Equals CurrentCultureIgnoreCase? { foreach (var a in profiles.Where(a => NetShWrapper.IsOpenAndAutoWifiProfile(a))) { Console.WriteLine(NetShWrapper.DeleteWifiProfile(a.Name)); } } } else { Console.WriteLine("{0}No WiFi profiles set to OPEN and AUTO connect were found." + "{0}Option: Run with /deleteautoopen to auto delete.", Environment.NewLine); } if (Environment.UserInteractive) { Pause(); } }