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();
        }
Example #2
0
        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);
            }
        }
Example #3
0
        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.");
            }
        }
        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();
            }
        }