Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        public void Init()
        {
            AppLog.Line(Program.fmt("Windows Update Manager, Version v{0} by David Xanatos", mVersion));
            AppLog.Line(Program.fmt("This Tool is Open Source under the GNU General Public License, Version 3\r\n"));

            mUpdateSession = new UpdateSession();
            mUpdateSession.ClientApplicationID = "Windows Update Manager";

            mUpdateServiceManager = new UpdateServiceManager();
            foreach (IUpdateService service in mUpdateServiceManager.Services)
            {
                if (service.Name == "Offline Sync Service")
                {
                    mUpdateServiceManager.RemoveService(service.ServiceID);
                }
                else
                {
                    mServiceList.Add(service.Name);
                }
            }

            mUpdateSearcher = mUpdateSession.CreateUpdateSearcher();

            int count = mUpdateSearcher.GetTotalHistoryCount();

            mUpdateHistory = mUpdateSearcher.QueryHistory(0, count);

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

            AppLog.Line(Program.fmt("Windows Update Agent Version: {0}", currentVersion));
        }
        public static IUpdateService2 GetService(this PSCmdlet command, bool force)
        {
            _command = command;

            DownloadWusscn2(force);

            IUpdateServiceManager manager = new UpdateServiceManager();

            return((IUpdateService2)manager.AddScanPackageService("Offline Sync Service", "D:\\wsusscn2.cab", 1));
        }
Ejemplo n.º 4
0
        private List <IUpdate5> GetPatches(UpdateSession session, Stream output)
        {
            UpdateServiceManager manager = new UpdateServiceManager();

            Bender.WriteLine("Found " + manager.Services.Count + " update services.", output);

            List <IUpdate5> updates = new List <IUpdate5>();

            foreach (IUpdateService2 service in manager.Services)
            {
                Bender.WriteLine("Retrieving patches from: " + service.Name, output);

                try
                {
                    var searcher = session.CreateUpdateSearcher();
                    searcher.ServerSelection = ServerSelection.ssWindowsUpdate;
                    searcher.ServiceID       = service.ServiceID;

                    ISearchResult searchresult = searcher.Search("");

                    UpdateCollection updatecollection = searchresult.Updates;

                    Bender.WriteLine("Found " + updatecollection.Count + " updates.", output);

                    foreach (IUpdate5 update in updatecollection)
                    {
                        if (!updates.Any(u => u.Title == update.Title))
                        {
                            updates.Add(update);
                        }
                    }
                }
                catch (COMException ex)
                {
                    Bender.WriteLine("Couldn't retrive patches: 0x" + ex.HResult.ToString("X"), output);
                    Bender.WriteLine(ex.ToString(), output);
                }
            }

            return(updates);
        }
Ejemplo n.º 5
0
        private List <IUpdate5> GetPatches(UpdateSession session)
        {
            UpdateServiceManager manager = new UpdateServiceManager();

            Log($"Found {manager.Services.Count} update services.");

            List <IUpdate5> updates = new List <IUpdate5>();

            foreach (IUpdateService2 service in manager.Services)
            {
                Log($"Retrieving patches from: {service.Name}");

                try
                {
                    var searcher = session.CreateUpdateSearcher();
                    searcher.ServerSelection = ServerSelection.ssWindowsUpdate;
                    searcher.ServiceID       = service.ServiceID;

                    ISearchResult searchresult = searcher.Search("");

                    UpdateCollection updatecollection = searchresult.Updates;

                    Log($"Found {updatecollection.Count} updates.");

                    foreach (IUpdate5 update in updatecollection)
                    {
                        if (!updates.Any(u => u.Title == update.Title))
                        {
                            updates.Add(update);
                        }
                    }
                }
                catch (COMException ex)
                {
                    Log($"Couldn't retrive patches: 0x{ex.HResult:X}");
                    Log(ex.ToString());
                }
            }

            return(updates);
        }
Ejemplo n.º 6
0
        private List<IUpdate5> GetPatches(UpdateSession session)
        {
            UpdateServiceManager manager = new UpdateServiceManager();

            Log("Found " + manager.Services.Count + " update services.");

            List<IUpdate5> updates = new List<IUpdate5>();
            foreach (IUpdateService2 service in manager.Services)
            {
                Log("Retrieving patches from: " + service.Name);

                try
                {
                    var searcher = session.CreateUpdateSearcher();
                    searcher.ServerSelection = ServerSelection.ssWindowsUpdate;
                    searcher.ServiceID = service.ServiceID;

                    ISearchResult searchresult = searcher.Search("");

                    UpdateCollection updatecollection = searchresult.Updates;

                    Log("Found " + updatecollection.Count + " updates.");

                    foreach (IUpdate5 update in updatecollection)
                    {
                        if (!updates.Any(u => u.Title == update.Title))
                        {
                            updates.Add(update);
                        }
                    }
                }
                catch (COMException ex)
                {
                    Log("Couldn't retrive patches: 0x" + ex.HResult.ToString("X"));
                    Log(ex.ToString());
                }
            }

            return updates;
        }