Ejemplo n.º 1
0
        static void process_exception(Exception e)
        {
            //if (ProgramRoutines.IsWebContext)
            //    throw e;

            LogMessage.Error(e);

            if (e is System.Security.SecurityException ||
                e is System.UnauthorizedAccessException
                )
            {
                if (Win.ProcessRoutines.ProcessHasElevatedPrivileges())
                {
                    LogMessage.Exit("Despite the app is running with elevated privileges, it still cannot write to the resgistry. Please fix the problem before using the app.");
                }
                LogMessage.Inform(Program.Name + " needs administatrator privileges to create an initial configuration in the registry. So it will restart now and ask for elevated privileges.");
                try
                {
                    ProcessRoutines.Restart(true);
                }
                catch (Exception ex)
                {
                    LogMessage.Exit(ex);
                }
            }
        }
Ejemplo n.º 2
0
        public static void Restart(bool as_administarator = false)
        {
            ProcessStartInfo psi = new ProcessStartInfo();

            psi.UseShellExecute  = true;
            psi.WorkingDirectory = Environment.CurrentDirectory;
            psi.FileName         = Application.ExecutablePath;
            if (as_administarator)
            {
                psi.Verb = "runas";
            }
            Process.Start(psi);
            ProcessRoutines.Exit();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Invoked by CliverBotCustomization to launch CliverBot
 /// </summary>
 static public void Run()
 {
     try
     {
         if (Properties.App.Default.SingleProcessOnly)
         {
             ProcessRoutines.RunSingleProcessOnly();
         }
         Session.Start();
         //         MainForm.This.Text = Program.Title;
         //       MainForm.This.ShowDialog();
     }
     catch (Exception e)
     {
         LogMessage.Exit(e);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Invoked by CliverBotCustomization to launch CliverBot
        /// </summary>
        static public void Run()
        {
            try
            {
                Bot.Config.Reload();

                if (Settings.App.SingleProcessOnly)
                {
                    ProcessRoutines.RunMeInSingleProcessOnly((string m) => { LogMessage.Inform(m); });
                }
                Session.Start();
                //         MainForm.This.Text = Program.Title;
                //       MainForm.This.ShowDialog();
            }
            catch (Exception e)
            {
                LogMessage.Exit(e);
            }
        }