示例#1
0
        public bool UnInstallUpdates(UpdateCollection Updates)
        {
            if (mInstalationJob != null)
            {
                return(false);
            }

            if (mInstaller == null)
            {
                mInstaller = mUpdateSession.CreateUpdateInstaller() as UpdateInstaller;
            }

            mInstaller.Updates = new UpdateCollection();
            foreach (IUpdate update in Updates)
            {
                if (!update.IsUninstallable)
                {
                    AppLog.Line(Program.fmt("Update can not be uninstalled: {0}", update.Title));
                    continue;
                }
                mInstaller.Updates.Add(update);
            }
            if (mDownloader.Updates.Count == 0)
            {
                AppLog.Line(Program.fmt("No updates selected or eligible for uninstallation"));
                return(false);
            }

            mCallback = new UpdateCallback(this);
            AppLog.Line(Program.fmt("Removing Updates... This may take several minutes."));
            mCallback.Install = false;
            mInstalationJob   = mInstaller.BeginUninstall(mCallback, mCallback, null);
            return(true);
        }
示例#2
0
文件: WuAgent.cs 项目: hobbit19/wumgr
        public WuAgent()
        {
            mInstance   = this;
            mDispatcher = Dispatcher.CurrentDispatcher;

            mUpdateDownloader           = new UpdateDownloader();
            mUpdateDownloader.Finished += DownloadsFinished;
            mUpdateDownloader.Progress += DownloadProgress;


            mUpdateInstaller           = new UpdateInstaller();
            mUpdateInstaller.Finished += InstallFinished;
            mUpdateInstaller.Progress += InstallProgress;

            dlPath = Program.appPath + @"\Downloads";

            WindowsUpdateAgentInfo info = new WindowsUpdateAgentInfo();
            var currentVersion          = info.GetInfo("ApiMajorVersion").ToString().Trim() + "." + info.GetInfo("ApiMinorVersion").ToString().Trim() + " (" + info.GetInfo("ProductVersionString").ToString().Trim() + ")";

            AppLog.Line("Windows Update Agent Version: {0}", currentVersion);

            mUpdateSession = new UpdateSession();
            mUpdateSession.ClientApplicationID = Program.mName;
            //mUpdateSession.UserLocale = 1033; // alwys show strings in englisch

            mUpdateServiceManager = new UpdateServiceManager();

            if (MiscFunc.parseInt(Program.IniReadValue("Options", "LoadLists", "0")) != 0)
            {
                LoadUpdates();
            }
        }
示例#3
0
        private bool InstallUpdates(UpdateCollection Updates)
        {
            if (mCallback != null)
            {
                return(false);
            }

            if (mInstaller == null)
            {
                mInstaller = mUpdateSession.CreateUpdateInstaller() as UpdateInstaller;
            }

            mInstaller.Updates = Updates;

            if (mDownloader.Updates.Count == 0)
            {
                AppLog.Line(Program.fmt("No updates selected or downloaded for instalation"));
                return(false);
            }

            mCallback = new UpdateCallback(this);
            AppLog.Line(Program.fmt("Installing Updates... This may take several minutes."));
            mCallback.Install = true;
            mInstalationJob   = mInstaller.BeginInstall(mCallback, mCallback, null);
            return(true);
        }