コード例 #1
0
        public static void Uninstall(UninstallOptions options)
        {
            if (!IsServiceInstalled())
            {
                //log.Error("Service can not be uninstalled. Service is not installed.");
                Environment.Exit(1);
            }

            if (!options.Force)
            {
                Console.WriteLine("Doy you really want to uninstall. Press key (y/n)");
                var key = Console.ReadKey();
                if (key.KeyChar != 'y')
                {
                    //log.Info("Operation canceled by user.");
                    Environment.Exit(1);
                }
            }

            try
            {
                ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
            }
            catch (InstallException ex)
            {
                if (ex.InnerException is SecurityException)
                {
                    SayNotEnaughRights();
                }
                else
                {
                    throw;
                }
            }
            Environment.Exit(0);
        }
コード例 #2
0
        public static void Uninstall(UninstallOptions options)
        {
            if (!IsServiceInstalled())
            {
                //log.Error("Service can not be uninstalled. Service is not installed.");
                Environment.Exit(1);
            }

            if (!options.Force)
            {
                Console.WriteLine("Doy you really want to uninstall. Press key (y/n)");
                var key = Console.ReadKey();
                if (key.KeyChar != 'y')
                {
                    //log.Info("Operation canceled by user.");
                    Environment.Exit(1);
                }
            }

            try
            {
                ManagedInstallerClass.InstallHelper(new[] {"/u", Assembly.GetExecutingAssembly().Location});
            }
            catch (InstallException ex)
            {
                if (ex.InnerException is SecurityException)
                {
                    SayNotEnaughRights();
                }
                else
                {
                    throw;
                }
            }
            Environment.Exit(0);
        }