private static void Main(string[] args)
        {
            if (args != null && args.Count() > 0)
            {
                foreach (var arg in args)
                {
                    switch(arg)
                    {
                        case "break":
                            Console.WriteLine("Program stopped, please attach debugger and then hit any key to continue.");
                            Console.ReadKey(true);
                            break;
                        case "debug":
                            _debug = true;
                            break;
                        case "noprocess":
                            _donotprocess = true;
                            break;
                    }
                }
            }

            ICollection<Bundle> Bundles = new List<Bundle>();
            ICollection<string> Userselected = new List<string>();
            var ip = new Primitives();

            ConsoleOperations.PrimitiveObject = ip;
            ConsoleOperations.SetUpLogging();

            ip.DoNotExecuteProcess = _donotprocess;
            ip.DebugReporting = _debug;

            try
            {
                // Change visual of console application to fit screen.
                ConsoleOperations.SetConsoleAttributes();

                // Check for permissions to run uninstall actions
                var elev = new ElevationDetection();
                if (!elev.Level)
                {
                    ConsoleOperations.SecurityWarning();
                }
                else
                {
                    Logger.Log("Running elevated or as administrator", Logger.MessageLevel.Information, AppName);
                }
                elev = null;

                // Define base variables for use of primitives object; adding filters, uninstall actions, logging location, and default location of data files
                ConsoleOperations.SetupPrimitivesValues(_debug, _donotprocess);

                var cmd = string.Empty;
                while (cmd != "quit")
                {
                    try
                    {
                        var cmdset = cmd.ToUpperInvariant().Split(' ');
                        cmd = cmdset[0];

                        Logger.Log(String.Format(CultureInfo.InvariantCulture, "Command value passed from user: {0}", cmd), Logger.MessageLevel.Information, AppName);
                        switch (cmd)
                        {
                            #region Command processor
                            case ConsoleOperations.COMMAND_COMPARE_TEMP:
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "Temp directory command started."), Logger.MessageLevel.Verbose, AppName);
                                ConsoleOperations.OpenTempDirectory();
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "Temp directory command ended."), Logger.MessageLevel.Verbose, AppName);
                                break;
                            case ConsoleOperations.COMMAND_COMPARE_SELECT:
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "Display select options command started."), Logger.MessageLevel.Verbose, AppName);
                                ConsoleOperations.SelectReleaseFromAvailableBundles();
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "Display select options command ended."), Logger.MessageLevel.Verbose, AppName);
                                break;
                            case ConsoleOperations.COMMAND_COMPARE_CREATE:
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "Save command started."), Logger.MessageLevel.Verbose, AppName);
                                ip.Processed = false;
                                ip.GetDataFromPdb();
                                ip.SaveAll();
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "Save command ended."), Logger.MessageLevel.Verbose, AppName);
                                break;
                            case ConsoleOperations.COMMAND_COMPARE_LOAD:
                                try
                                {
                                    Logger.Log(String.Format(CultureInfo.InvariantCulture, "Load command started."), Logger.MessageLevel.Verbose, AppName);
                                    // Load up object files from disk
                                    Bundles = ip.LoadFromFiles();
                                    Console.WriteLine("Files loaded successfully.");
                                    Logger.Log(String.Format(CultureInfo.InvariantCulture, "Load command ended."), Logger.MessageLevel.Verbose, AppName);
                                }
                                catch (Exception ex)
                                {
                                    Logger.Log(ex, AppName);
                                    Console.WriteLine(ex.Message);
                                }
                                break;
                            case ConsoleOperations.COMMAND_COMPARE_INSTALLED:
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "What is installed command started."), Logger.MessageLevel.Verbose, AppName);
                                // Using WindowsInstaller.Deployment to determine what is installed on the machine.
                                var packages = ip.GetAllInstalledItems;

                                foreach (Package package in packages)
                                {
                                    var pname = package.ProductName.PadRight(50);
                                    var pcode = package.ProductCode.ToString().PadRight(30);
                                    Console.WriteLine(Logger.Log(String.Format(CultureInfo.InvariantCulture, "{0} {1}", pcode, pname), Logger.MessageLevel.Information, AppName));
                                }
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "What is installed command ended."), Logger.MessageLevel.Verbose, AppName);
                                break;
                            case ConsoleOperations.COMMAND_COMPARE_DIRECTORY:
                                ConsoleOperations.ChangeWorkingDirectory(cmdset);
                                break;
                            case ConsoleOperations.COMMAND_COMPARE_LIST:  // What releases were loaded from config files or wixpdbs
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "List releases command started."), Logger.MessageLevel.Verbose, AppName);
                                Console.WriteLine(ConsoleOperations.PrintReleaseInfo());
                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "List releases command ended."), Logger.MessageLevel.Verbose, AppName);
                                break;
                            default:
                                #region Make sure something is selected before executing these commands
                                // Check for if something was selected
                                if (ip.Releases.FirstOrDefault(x => x.Selected) != null)
                                {
                                    Logger.Log(String.Format(CultureInfo.InvariantCulture, "Selection count is greater than 0."), Logger.MessageLevel.Information, AppName);
                                    Logger.Log(String.Format(CultureInfo.InvariantCulture, "Check if Bundles object has an objects populated."), Logger.MessageLevel.Verbose, AppName);
                                    if (!ip.Processed)
                                    {
                                        Logger.Log(String.Format(CultureInfo.InvariantCulture, "Populate Bundles object started"), Logger.MessageLevel.Verbose, AppName);
                                        Bundles = IfNotProcessed(ip);
                                        Logger.Log(String.Format(CultureInfo.InvariantCulture, "Populate Bundles object ended"), Logger.MessageLevel.Verbose, AppName);
                                    }
                                    else { Bundles = ip.Releases.Where(x => x.Selected).ToList(); }

                                    switch (cmd) // Commands that require release(s) to be selected
                                    {
                                        case ConsoleOperations.COMMAND_COMPARE_UNINSTALL:
                                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Uninstall command started."), Logger.MessageLevel.Verbose, AppName);
                                            ProcessUninstallBundles(ip, Bundles);
                                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Uninstall command ended."), Logger.MessageLevel.Verbose, AppName);
                                            break;
                                        case ConsoleOperations.COMMAND_COMPARE_MSIS:
                                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Uninstall MSI command started."), Logger.MessageLevel.Verbose, AppName);
                                            ProcessUninstallMSIs(ip);
                                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Uninstall MSI command ended."), Logger.MessageLevel.Verbose, AppName);
                                            break;
                                        case ConsoleOperations.COMMAND_COMPARE_VSINSTALLED:
                                            // On a given machine, this what VS installed.
                                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "VS Installs command started."), Logger.MessageLevel.Verbose, AppName);
                                            foreach (Bundle bundle in ip.GetAllInstalledItemsCompareWixPdb)
                                            {
                                                Console.WriteLine(bundle.Name);
                                                foreach (Package package in bundle.Packages)
                                                {
                                                    Logger.Log(String.Format(CultureInfo.InvariantCulture, "-- {0}", ip.ApplyFilter(package.ProductName).PadRight(40) + package.ProductCode.ToString().PadRight(30)), Logger.MessageLevel.Information, AppName);
                                                    Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "-- {0}", ip.ApplyFilter(package.ProductName).PadRight(40) + package.ProductCode.ToString().PadRight(30)));
                                                }
                                            }
                                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "VS Installs command ended."), Logger.MessageLevel.Verbose, AppName);
                                            break;
                                        case ConsoleOperations.COMMAND_COMPARE_LOGSELECTED:
                                            // Writes out product name, product code, and package type
                                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Log selected command started."), Logger.MessageLevel.Verbose, AppName);
                                            foreach (Bundle bundle in Bundles)
                                            {
                                                Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Logging start: {0}", bundle.Name));
                                                foreach (Package package in bundle.Packages)
                                                {
                                                    Logger.Log(String.Format(CultureInfo.InvariantCulture, "-- {0}", ip.ApplyFilter(package.ProductName).PadRight(80) + package.ChainingPackage.PadRight(60) + package.ProductCode.ToString().PadRight(45)) + package.Type.ToString().PadRight(30), Logger.MessageLevel.Information, AppName);
                                                }
                                                Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Logging end: {0}", bundle.Name));
                                            }
                                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Log selected command started."), Logger.MessageLevel.Verbose, AppName);
                                            break;
                                    }
                                }
                                else if ((Userselected.Count == 0) && (!String.IsNullOrEmpty(cmd)))
                                {
                                    Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Use the 'Select' command to determine which bundles you want to try \r\n to uninstall"));
                                }
                                break;  // End check for if something was selected
                                #endregion
                        }
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(Logger.Log(ex, AppName));
                    }

                    if (ConsoleOperations.Options.Where(x => x.CommandCompareValue.Contains(cmd)) == null)
                    {
                        Console.WriteLine("\r\nInvalid command. Please try again.\r");
                    }

                    if (!String.IsNullOrEmpty(cmd))
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("\r\n\r\nPress any key to continue.");
                        Console.ReadLine();
                        Console.ResetColor();
                        Console.Clear();
                    }

                    ConsoleOperations.GetUsage();
                    cmd = Console.ReadLine();
                    Console.Clear();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex, AppName);
            }
            finally
            {
                ip.Dispose();
            }
        }
        private static int Main(string[] args)
        {
            string wixpdbsPathsFile = string.Empty;
            string[] wixpdbsPaths = null;
            string dataFilePath = string.Empty;
            //args = new string[] { "noprocess", @"/wixpdbs:C:\Users\user\Desktop\test\paths.txt" };
            //args = new string[] { "noprocess", @"/binfile:C:\Users\user\Desktop\test\DataFile.bin" };
            //args = new string[] { "noprocess", @"/binfile:C:\Users\user\Desktop\test\DataFile.bin", @"/wixpdbs:\\myshare\Drops\user\wixpdbsPS\sub\Files.txt" };
            if (args != null && args.Count() > 0)
            {
                foreach (var arg in args)
                {
                    switch(arg.ToLowerInvariant())
                    {
                        case "help":
                        case "/help":
                        case "/?":
                            PrintUsage();
                            return 0;
                        case "break":
                            Console.WriteLine("Program stopped, please attach debugger and then hit any key to continue.");
                            Console.ReadKey(true);
                            break;
                        case "debug":
                            _debug = true;
                            break;
                        case "noprocess":
                            _donotprocess = true;
                            break;
                        default:
                            // Path to the file containing a list of paths to the wixpdbs.
                            // e.g. /wixpdbs:c:\myPaths.txt
                            if (arg.StartsWith("/wixpdbs:", StringComparison.OrdinalIgnoreCase))
                            {
                                wixpdbsPathsFile = arg.Substring("/wixpdbs:".Length);
                                wixpdbsPaths = File.ReadAllLines(wixpdbsPathsFile);
                            }
                            // Path to the file containing the DataFile.bin; if no file is passed in, it will use the embedded one.
                            // e.g. /binfile:C:\DataFile.bin
                            else if (arg.StartsWith("/binfile:", StringComparison.OrdinalIgnoreCase))
                            {
                                dataFilePath = arg.Substring("/binfile:".Length);
                            }
                            break;
                    }
                }
            }

            var ip = new Primitives();

            ConsoleOperations.PrimitiveObject = ip;
            ConsoleOperations.SetUpLogging();

            ip.DoNotExecuteProcess = _donotprocess;
            ip.DebugReporting = _debug;

            try
            {
                // Check for permissions to run uninstall actions
                var elev = new ElevationDetection();
                if (!elev.Level)
                {
                    ConsoleOperations.SecurityWarning();
                    return 0;
                }
                else
                {
                    Logger.Log("Running elevated or as administrator", Logger.MessageLevel.Information, AppName);
                }
                elev = null;

                // Define base variables for use of primitives object; adding filters, uninstall actions, logging location, and default location of data files
                ConsoleOperations.SetupPrimitivesValues(_debug, _donotprocess);

                // If /wixpdbs is used, .bin data file is generated for the user.
                if (wixpdbsPaths != null && wixpdbsPaths.Length > 0)
                {
                    if (!string.IsNullOrEmpty(dataFilePath) && File.Exists(dataFilePath))
                    {
                        Logger.LogWithOutput(string.Format("Loading from {0}", dataFilePath));
                        ip.LoadFromDataFile(dataFilePath);
                    }

                    Logger.LogWithOutput("Generating data file from wixpdbs ....");
                    foreach (var wixpdbPath in wixpdbsPaths)
                    {
                        ip.LoadFromWixpdb(wixpdbPath);
                    }

                    ip.SaveToDataFile();
                    Logger.Log("Data File generation operation is successful.  Exiting ...", Logger.MessageLevel.Information, AppName);
                    return 0;
                }
                // Else uninstall Visual Studio 2013/2015/vNext
                else
                {
                    if (!string.IsNullOrEmpty(dataFilePath) && File.Exists(dataFilePath))
                    {
                        ip.LoadFromDataFile(dataFilePath);
                    }
                    else
                    {
                        // load from embedded.
                        var assembly = Assembly.GetExecutingAssembly();
                        var dataFile = "Microsoft.VisualStudio.Setup.DataFile.bin";

                        using (Stream stream = assembly.GetManifestResourceStream(dataFile))
                        {
                            ip.LoadFromDataFile(stream);
                        }
                    }

                    ip.InstalledVisualStudioReport();
                    Logger.LogWithOutput("WARNING: This executable is designed to cleanup/scorch all Preview/RC/RTM releases of Visual Studio 2013, Visual Studio 2015 and Visual Studio vNext.");
                    Logger.LogWithOutput("It should be used as the last resort to clean up the user's system before resorting to reimaging the machine. ");
                    Logger.LogWithOutput("Would you like to continue? [Y/N]");
                    var action = Console.ReadLine();
                    if (!string.IsNullOrEmpty(action) && action.StartsWith("y", StringComparison.OrdinalIgnoreCase))
                    {
                        // cache the vs dirs in memory before uninstalling.
                        var vsDirs = GetVisualStudioInstallationDirs();

                        int exitCode = ip.Uninstall();

                        if (exitCode == 3010)
                        {
                            Logger.LogWithOutput("Bundle requested to reboot the system.  Please reboot your computer and run this application again.");
                            return 3010;
                        }
                        ip.CleanupVisualStudioFolders(vsDirs);
                        ip.CleanupSecondaryInstallerCache();
                        ip.CleanupVisualStudioRegistryHives();
                    }
                    else
                    {
                        Logger.LogWithOutput("Exiting ...");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex, AppName);
            }
            finally
            {
                ip.Dispose();
            }

            return 0;
        }