コード例 #1
0
        public void TabClosed()
        {
            Configuration.WebMediaPortalHosting.Port = Int32.Parse(txtPort.Text);
            Configuration.WebMediaPortalHosting.EnableTLS = cbHTTPS.IsChecked.GetValueOrDefault(false);
            Configuration.WebMediaPortalHosting.PortTLS = Int32.Parse(txtHTTPSPort.Text);
            Configuration.WebMediaPortalHosting.Save();

            // restart
            if (UacServiceHelper.IsAdmin())
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var wsh = new WindowsServiceHandler("MPExtended WebMediaPortal");
                        wsh.Execute(ServiceCommand.Restart);
                    }
                    catch (Exception ex)
                    {
                        Log.Warn("Failed to restart WebMediaPortal hosting process", ex);
                    }
                });
            }
            else
            {
                UacServiceHelper.RunUacServiceHandler("/command:webmphosting /action:restart");
            }
        }
コード例 #2
0
ファイル: Service.cs プロジェクト: changer4/MPExtended
        public static void RestartService()
        {
            // restart the service
            if (!UacServiceHelper.IsAdmin())
            {
                Log.Debug("Service: no admin rights, use UacServiceHandler");
                UacServiceHelper.RestartService();
            }
            else if (UacServiceHelper.IsAdmin())
            {
                Log.Debug("Service: have admin rights, restart ourselves");
                var handler = new WindowsServiceHandler(SERVICE_NAME);
                handler.Execute(ServiceCommand.Restart);
            }

            ShouldRestart = false;
        }