/// <summary>
        ///     Checks that the MSDTC service is running and configured correctly, and if not
        ///     takes the necessary corrective actions to make it so.
        /// </summary>
        public void StartDtcIfNecessary()
        {
            var processUtil = new ProcessUtil(Host);

            if (DoesSecurityConfigurationRequireRestart(true))
            {
                processUtil.ChangeServiceStatus(Controller, ServiceControllerStatus.Stopped, Controller.Stop);
            }

            processUtil.ChangeServiceStatus(Controller, ServiceControllerStatus.Running, Controller.Start);
        }
예제 #2
0
        /// <summary>
        ///     Checks that the MSDTC service is running and configured correctly, and if not
        ///     takes the necessary corrective actions to make it so.
        /// </summary>
        public void StartDtcIfNecessary()
        {
            var processUtil = new ProcessUtil(Host);

            if (DoesSecurityConfigurationRequireRestart(true))
            {
                processUtil.ChangeServiceStatus(Controller, ServiceControllerStatus.Stopped, Controller.Stop);
            }

            processUtil.ChangeServiceStatus(Controller, ServiceControllerStatus.Running, Controller.Start);
        }
        /// <summary>
        /// Checks that MSMQ is installed, configured correctly, and started, and if not takes the necessary corrective actions to make it so.
        /// </summary>
        public bool StartMsmqIfNecessary()
        {
            var processUtil = new ProcessUtil(Host);

            if (!InstallMsmqIfNecessary())
            {
                return(false);
            }

            try
            {
                using (var controller = new ServiceController("MSMQ"))
                {
                    if (IsStopped(controller))
                    {
                        processUtil.ChangeServiceStatus(controller, ServiceControllerStatus.Running, controller.Start);
                    }
                }
            }
            catch (InvalidOperationException)
            {
                WriteWarning("MSMQ windows service not found! You may need to reboot after MSMQ has been installed.");
                return(false);
            }

            return(true);
        }
    /// <summary>
    /// Checks that MSMQ is installed, configured correctly, and started, and if not takes the necessary corrective actions to make it so.
    /// </summary>
    public bool StartMsmqIfNecessary()
    {
        var processUtil = new ProcessUtil(Host);

        if (!InstallMsmqIfNecessary())
        {
            return false;
        }

        try
        {
            using (var controller = new ServiceController("MSMQ"))
            {
                if (IsStopped(controller))
                {
                    processUtil.ChangeServiceStatus(controller, ServiceControllerStatus.Running, controller.Start);
                }
            }
        }
        catch (InvalidOperationException)
        {
            WriteWarning("MSMQ windows service not found! You may need to reboot after MSMQ has been installed.");
            return false;
        }

        return true;
    }