/// <summary>
        /// Runs the specified application using the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public void Run(string[] args)
        {
            Logging.Log("Started the Server Registration Manager.");

            //  Show the welcome.
            ShowWelcome();

            //  If we have no verb or target or our verb is help, show the help.
            if (args.Length == 0 || args.First() == VerbHelp)
            {
                ShowHelpAction.Execute(outputService);
                return;
            }

            //  Get the architecture.
            var registrationType = Environment.Is64BitOperatingSystem ? RegistrationType.OS64Bit : RegistrationType.OS32Bit;

            //  Get the verb, target and parameters.
            var verb       = args[0];
            var target     = args.Length > 1 ? args[1] : null; // TODO tidy this up.
            var parameters = args.Skip(1).ToArray();

            //Allow user to override registrationType with -os32 or -os64
            if (parameters.Any(p => p.Equals(ParameterOS32, StringComparison.InvariantCultureIgnoreCase)))
            {
                registrationType = RegistrationType.OS32Bit;
            }
            else if (parameters.Any(p => p.Equals(ParameterOS64, StringComparison.InvariantCultureIgnoreCase)))
            {
                registrationType = RegistrationType.OS64Bit;
            }

            //  Based on the verb, perform the action.
            if (verb == VerbInstall)
            {
                InstallServer(target, registrationType, parameters.Any(p => p == ParameterCodebase));
            }
            else if (verb == VerbUninstall)
            {
                UninstallServer(target, registrationType);
            }
            else if (verb == VerbConfig)
            {
                ConfigAction.Execute(outputService, parameters);
            }
            else if (verb == VerbEnableEventLog)
            {
                EnableEventLogAction.Execute(outputService);
            }
            else
            {
                ShowHelpAction.Execute(outputService);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Runs the specified application using the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public void Run(string[] args)
        {
            Logging.Log("Started the Server Registration Manager.");

            //  Show the welcome.
            ShowWelcome();

            //  If we have no verb or target or our verb is help, show the help.
            if (args.Length == 0 || args.First() == VerbHelp)
            {
                ShowHelpAction.Execute(outputService);
                return;
            }

            //  Get the architecture.
            var registrationType = RegistrationType.OS64Bit;

#if WIN32
            registrationType = RegistrationType.OS32Bit;
#endif

            //  Get the verb, target and parameters.
            var verb       = args[0];
            var target     = args.Length > 1 ? args[1] : (string)null; // TODO tidy this up.
            var parameters = args.Skip(1);

            //  Based on the verb, perform the action.
            if (verb == VerbInstall)
            {
                InstallServer(target, registrationType, parameters.Any(p => p == ParameterCodebase));
            }
            else if (verb == VerbUninstall)
            {
                UninstallServer(target, registrationType);
            }
            else if (verb == VerbConfig)
            {
                ConfigAction.Execute(outputService, parameters);
            }
            else if (verb == VerbEnableEventLog)
            {
                EnableEventLogAction.Execute(outputService);
            }
            else
            {
                ShowHelpAction.Execute(outputService);
            }
        }