コード例 #1
0
        static private void ExecOnStart()
        {
            if (int.Parse(IniReadValue("OnStart", "EnableWuAuServ", "0")) != 0)
            {
                Agent.EnableWuAuServ(true);
            }

            string OnStart = IniReadValue("OnStart", "Exec", "");

            if (OnStart.Length > 0)
            {
                DoExec(PrepExec(OnStart, MiscFunc.parseInt(IniReadValue("OnStart", "Silent", "1")) != 0), true);
            }
        }
コード例 #2
0
        static private void ExecOnStart()
        {
            string ToolsINI = GetToolsPath() + @"\Tools.ini";

            if (int.Parse(IniReadValue("OnStart", "EnableWuAuServ", "0", ToolsINI)) != 0)
            {
                Agent.EnableWuAuServ(true);
            }

            string OnStart = IniReadValue("OnStart", "Exec", "", ToolsINI);

            if (OnStart.Length > 0)
            {
                DoExec(PrepExec(OnStart, MiscFunc.parseInt(IniReadValue("OnStart", "Silent", "1", ToolsINI)) != 0), true);
            }
        }
コード例 #3
0
ファイル: WuMgr.cs プロジェクト: hobbit19/wumgr
        public WuMgr()
        {
            InitializeComponent();

            //notifyIcon1.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location);
            notifyIcon.Text = Program.mName;

            if (Program.TestArg("-tray"))
            {
                allowshowdisplay   = false;
                notifyIcon.Visible = true;
            }

            this.Text = MiscFunc.fmt("{0} v{1} by David Xanatos", Program.mName, Program.mVersion);

            toolTip.SetToolTip(btnSearch, "Search");
            toolTip.SetToolTip(btnInstall, "Install");
            toolTip.SetToolTip(btnDownload, "Download");
            toolTip.SetToolTip(btnHide, "Hide");
            toolTip.SetToolTip(btnGetLink, "Get Links");
            toolTip.SetToolTip(btnUnInstall, "Uninstall");
            toolTip.SetToolTip(btnCancel, "Cancel");

            btnSearch.Image    = (Image)(new Bitmap(global::wumgr.Properties.Resources.icons8_available_updates_32, new Size(25, 25)));
            btnInstall.Image   = (Image)(new Bitmap(global::wumgr.Properties.Resources.icons8_software_installer_32, new Size(25, 25)));
            btnDownload.Image  = (Image)(new Bitmap(global::wumgr.Properties.Resources.icons8_downloading_updates_32, new Size(25, 25)));
            btnUnInstall.Image = (Image)(new Bitmap(global::wumgr.Properties.Resources.icons8_trash_32, new Size(25, 25)));
            btnHide.Image      = (Image)(new Bitmap(global::wumgr.Properties.Resources.icons8_hide_32, new Size(25, 25)));
            btnGetLink.Image   = (Image)(new Bitmap(global::wumgr.Properties.Resources.icons8_link_32, new Size(25, 25)));
            btnCancel.Image    = (Image)(new Bitmap(global::wumgr.Properties.Resources.icons8_cancel_32, new Size(25, 25)));

            AppLog.Logger += LineLogger;

            foreach (string line in AppLog.GetLog())
            {
                logBox.AppendText(line + Environment.NewLine);
            }
            logBox.ScrollToCaret();


            agent                = WuAgent.GetInstance();
            agent.Progress      += OnProgress;
            agent.UpdatesChaged += OnUpdates;
            agent.Finished      += OnFinished;

            if (!agent.IsActive())
            {
                if (MessageBox.Show("Windows Update Service is not available, try to start it?", Program.mName, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    agent.EnableWuAuServ();
                    agent.Init();
                }
            }

            mSuspendUpdate        = true;
            chkDrivers.CheckState = (CheckState)GPO.GetDriverAU();
            int day, time;

            dlPolMode.SelectedIndex   = GPO.GetAU(out day, out time);
            dlShDay.SelectedIndex     = day; dlShTime.SelectedIndex = time;
            chkBlockMS.CheckState     = (CheckState)GPO.GetBlockMS();
            dlAutoCheck.SelectedIndex = MiscFunc.parseInt(GetConfig("AutoUpdate", "0"));
            chkAutoRun.Checked        = Program.IsAutoStart();
            IdleDelay        = MiscFunc.parseInt(GetConfig("IdleDelay", "20"));
            chkNoUAC.Checked = Program.IsSkipUacRun();


            chkOffline.Checked  = MiscFunc.parseInt(GetConfig("Offline", "1")) != 0;
            chkDownload.Checked = MiscFunc.parseInt(GetConfig("Download", "1")) != 0;
            chkManual.Checked   = MiscFunc.parseInt(GetConfig("Manual", "0")) != 0;
            chkOld.Checked      = MiscFunc.parseInt(GetConfig("IncludeOld", "0")) != 0;
            string source = GetConfig("Source", "Windows Update");

            string Online = Program.GetArg("-online");

            if (Online != null)
            {
                chkOffline.Checked = false;
                if (Online.Length > 0)
                {
                    source = agent.GetServiceName(Online, true);
                }
            }

            string Offline = Program.GetArg("-offline");

            if (Offline != null)
            {
                chkOffline.Checked = true;
                if (Offline.Equals("download", StringComparison.CurrentCultureIgnoreCase))
                {
                    chkDownload.Checked = true;
                }
                else if (Offline.Equals("no_download", StringComparison.CurrentCultureIgnoreCase))
                {
                    chkDownload.Checked = false;
                }
            }

            if (Program.TestArg("-manual"))
            {
                chkManual.Checked = true;
            }

            try {
                LastCheck = DateTime.Parse(GetConfig("LastCheck", ""));
                AppLog.Line("Last Checked for updates: {0}", LastCheck.ToString());
            } catch { }

            LoadProviders(source);

            chkMsUpd.Checked = agent.IsActive() && agent.TestService(WuAgent.MsUpdGUID);

            if (GPO.IsRespected() == 0)
            {
                dlPolMode.Enabled = false;
                //toolTip.SetToolTip(dlPolMode, "Windows 10 Pro and Home do not respect this GPO setting");
            }

            chkHideWU.Enabled = GPO.IsRespected() != 2;
            chkHideWU.Checked = GPO.IsUpdatePageHidden();

            mSuspendUpdate = false;

            mToolsMenu      = new MenuItem();
            mToolsMenu.Text = "&Tools";

            BuildToolsMenu();

            notifyIcon.ContextMenu = new ContextMenu();

            MenuItem menuAbout = new MenuItem();

            menuAbout.Text   = "&About";
            menuAbout.Click += new System.EventHandler(menuAbout_Click);

            MenuItem menuExit = new MenuItem();

            menuExit.Text   = "E&xit";
            menuExit.Click += new System.EventHandler(menuExit_Click);

            notifyIcon.ContextMenu.MenuItems.AddRange(new MenuItem[] { mToolsMenu, menuAbout, new MenuItem("-"), menuExit });


            IntPtr MenuHandle = GetSystemMenu(this.Handle, false);                    // Note: to restore default set true

            InsertMenu(MenuHandle, 5, MF_BYPOSITION | MF_SEPARATOR, 0, string.Empty); // <-- Add a menu seperator
            InsertMenu(MenuHandle, 6, MF_BYPOSITION | MF_POPUP, (int)mToolsMenu.Handle, "Tools");
            InsertMenu(MenuHandle, 7, MF_BYPOSITION, MYMENU_ABOUT, "&About");


            UpdateCounts();
            SwitchList(UpdateLists.UpdateHistory);

            doUpdte = Program.TestArg("-update");

            mTimer          = new Timer();
            mTimer.Interval = 1000; // once epr second
            mTimer.Tick    += OnTimedEvent;
            mTimer.Enabled  = true;

            Program.ipc.PipeMessage += new PipeIPC.DelegateMessage(PipesMessageHandler);
            Program.ipc.Listen();
        }