CheckNow() public method

public CheckNow ( ) : void
return void
Beispiel #1
0
        static int Main(string[] args)
        {
            try
            {
                bool add    = false;
                bool remove = false;
                bool check  = true;

                if (!IsElevated())
                {
                    System.Diagnostics.Debug.Print("XenUpdater.exe must be run by an elevated administrator account");
                    return((int)HRESULT.E_ACCESSDENIED);
                }

                // check params for config options...
                foreach (string arg in args)
                {
                    switch (arg.ToLower())
                    {
                    case "add":
                        add   = true;
                        check = false;
                        break;

                    case "remove":
                        remove = true;
                        check  = false;
                        break;

                    case "check":
                        check = true;
                        break;

                    default:
                        throw new ArgumentException(arg);
                    }
                }
                if (add && !remove && !check)
                {
                    using (Tasks tasks = new Tasks())
                    {
                        tasks.AddTask();
                    }
                }
                if (remove && !add && !check)
                {
                    using (Tasks tasks = new Tasks())
                    {
                        tasks.RemoveTask();
                    }
                }
                if (check && !add && !remove)
                {
                    AutoUpdate auto = new AutoUpdate();
                    auto.CheckNow();
                }
                return(0);
            }
            catch (UnauthorizedAccessException e)
            {
                System.Diagnostics.Debug.Print("Exception: " + e.ToString());
                return((int)HRESULT.E_ACCESSDENIED);
            }
            catch (FormatException e)
            {
                System.Diagnostics.Debug.Print("Exception: " + e.ToString());
                return((int)HRESULT.E_INVALIDARG);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Print("Exception: " + e.ToString());
                return(-1); // TODO: Return the HRESULT of this exception
            }
        }
Beispiel #2
0
        static int Main(string[] args)
        {
            int result = -2;
            if (SingleApp.IsRunning())
                return -3;

            try
            {
                bool add = false;
                bool remove = false;
                bool check = true;

                if (!IsElevated())
                {
                    Program.Log("XenUpdater.exe must be run by an elevated administrator account");
                    return (int)HRESULT.E_ACCESSDENIED;
                }

                // check params for config options...
                foreach (string arg in args)
                {
                    switch (arg.ToLower())
                    {
                        case "add":
                            add = true;
                            check = false;
                            break;
                        case "remove":
                            remove = true;
                            check = false;
                            break;
                        case "check":
                            check = true;
                            break;
                        default:
                            throw new ArgumentException(arg);
                    }
                }
                if (add && !remove && !check)
                {
                    using (Tasks tasks = new Tasks())
                    {
                        tasks.AddTask();
                    }
                }
                if (remove && !add && !check)
                {
                    using (Tasks tasks = new Tasks())
                    {
                        tasks.RemoveTask();
                    }
                }
                if (check && !add && !remove)
                {
                    AutoUpdate auto = new AutoUpdate();
                    auto.CheckNow();
                }
                result = 0;
            }
            catch (UnauthorizedAccessException e)
            {
                Program.Log("Exception: " + e.ToString());
                result = (int)HRESULT.E_ACCESSDENIED;
            }
            catch (FormatException e)
            {
                Program.Log("Exception: " + e.ToString());
                result = (int)HRESULT.E_INVALIDARG;
            }
            catch (Exception e)
            {
                Program.Log("Exception: " + e.ToString());
                result = -1; // TODO: Return the HRESULT of this exception
            }

            return result;
        }