Exemple #1
0
        static int Uninstall()
        {
            logger.WriteLine();
            logger.WriteLine($"Unregister... version {AssemblyInfo.Version}");

            try
            {
                // unregister is more lenient than register... if any of these
                // actions don't succeed, we can still complete with SUCCESS

                var ok0 = new ShutdownOneNoteAction(logger, stepper).Uninstall() == CustomAction.SUCCESS;
                var ok1 = new ProtocolHandlerAction(logger, stepper).Uninstall() == CustomAction.SUCCESS;
                var ok2 = new TrustedProtocolAction(logger, stepper).Uninstall() == CustomAction.SUCCESS;
                var ok3 = new RegistryWowAction(logger, stepper).Uninstall() == CustomAction.SUCCESS;

                if (ok0 && ok1 && ok2 && ok3)
                {
                    logger.WriteLine("completed successfully");
                }
                else
                {
                    logger.WriteLine("completed with warnings");
                }

                return(CustomAction.SUCCESS);
            }
            catch (Exception exc)
            {
                logger.WriteLine("error unregistering");
                logger.WriteLine(exc);
                return(CustomAction.FAILURE);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            // hide this console window
            // - This program needs to run as a console app so it blocks while the edge webview2
            // - installer runs and completes. But we want to hide the window so the user can't
            // - close it while the installer is running, leaving it in a bad state.
            // - Can comment this out for debugging
            ShowWindow(Process.GetCurrentProcess().MainWindowHandle, 0);

            if (args.Length == 0 || string.IsNullOrEmpty(args[0]))
            {
                // nothing to do
                return;
            }

            logger  = new Logger("OneMoreSetup");
            stepper = new Stepper();

            ReportContext();

            int status;

            switch (args[0])
            {
            case "--install":
                status = Install();
                break;

            case "--uninstall":
                status = Uninstall();
                break;

            // direct calls for testing...

            case "--install-activesetup":
                status = new ActiveSetupAction(logger, stepper).Install();
                break;

            case "--install-edge":
                status = new EdgeWebViewAction(logger, stepper).Install();
                break;

            case "--install-handler":
                status = new ProtocolHandlerAction(logger, stepper).Install();
                break;

            case "--install-registrywow":
                status = new RegistryWowAction(logger, stepper).Install();
                break;

            case "--install-shutdown":
                status = new ShutdownOneNoteAction(logger, stepper).Install();
                break;

            case "--install-trusted":
                status = new TrustedProtocolAction(logger, stepper).Install();
                break;

            case "--uninstall-edge":
                status = new EdgeWebViewAction(logger, stepper).Uninstall();
                break;

            case "--uninstall-registrywow":
                status = new RegistryWowAction(logger, stepper).Uninstall();
                break;

            case "--uninstall-shutdown":
                status = new ShutdownOneNoteAction(logger, stepper).Uninstall();
                break;

            default:
                logger.WriteLine($"unrecognized command: {args[0]}");
                status = CustomAction.FAILURE;
                break;
            }

            Environment.Exit(status);
        }