Example #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();
            }
        }
Example #2
0
        static void WUStatus()
        {
            WindowsUpdateAgentInfo wuai = new WindowsUpdateAgentInfo();

            Console.Write((string)wuai.GetInfo("ProductVersionString"));

            AutomaticUpdatesClass auc = new WUApiLib.AutomaticUpdatesClass();

            Console.Write("|");
            Console.Write(auc.Settings.NotificationLevel.ToString().Replace("aunl", "").Replace("Installation", "Install"));

            if (auc.Settings.NotificationLevel == AutomaticUpdatesNotificationLevel.aunlScheduledInstallation)
            {
                AutomaticUpdates au = new AutomaticUpdates();
                Console.Write("|");
                Console.Write(au.ServiceEnabled.ToString());

                Console.Write("|");
                Console.Write(au.Settings.ScheduledInstallationDay.ToString().Replace("ausid", "").Replace("Every", "Every ") + "|" + FixHour(au.Settings.ScheduledInstallationTime.ToString()) + ":00");
            }
            else
            {
                Console.Write("||");  //no schedule if endpoint is set to anything other than scheduled installation
            }


            Console.WriteLine("");
        }
Example #3
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));
        }
Example #4
0
        private static bool IsWuavOutDated()
        {
            var xmlDoc = new XmlDocument(); //* create an xml document object.

            //xmlDoc.Load(Path.Combine(tempDir, xmlFileName));
            xmlDoc.LoadXml(WuRedistXml);

            var runningPlatform = (SystemInfo.IsWindows64Bit) ? "x64" : "x86";
            var xpath           = String.Format(@"/WURedist/StandaloneRedist/architecture[@name=""{0}""]", runningPlatform);
            var node            = xmlDoc.SelectSingleNode(xpath);

            try
            {
                var agent = new WindowsUpdateAgentInfo();
                //WindowsUpdateAgentInfoClass wuainfo = new WindowsUpdateAgentInfoClass();
                //int wualatestversion = (int)wuainfo.GetInfo("ApiMajorVersion");

                if (node != null)
                {
                    if (node.Attributes != null)
                    {
                        var latestVersion  = node.Attributes["clientVersion"].Value.Trim();
                        var currentVersion = agent.GetInfo("ProductVersionString").ToString().Trim();

                        if (currentVersion.Equals(latestVersion))
                        {
                            Logger.Log("WUA is up to date. Current version: {0}, Minimun required version: {1}.",
                                       LogLevel.Info,
                                       currentVersion, latestVersion);
                            return(false);
                        }

                        var latest  = latestVersion.Split('.');
                        var current = currentVersion.Split('.');

                        for (var i = 0; i < 4; i++)
                        {
                            //Take into account that the latest version can "never" be less than the current version.
                            if (Convert.ToInt32(latest[i]) <= Convert.ToInt32(current[i]))
                            {
                                continue;
                            }
                            Logger.Log("WUA is outdated. Current version: {0}, Minimun required version: {1}.", LogLevel.Error, currentVersion, latestVersion);
                            return(true);
                        }
                        Logger.Log("WUA is up to date. Current version: {0}, Minimun required version: {1}.", LogLevel.Info, currentVersion, latestVersion);
                    }
                }
                return(false);
            }
            catch (Exception e)
            {
                Logger.Log("Exception when attempting to check WUA version, Assuming out of Date.", LogLevel.Error);
                Logger.LogException(e);
                return(true);
            }
        }
Example #5
0
        private void WinUpdatesTestGOButton_Click(object sender, EventArgs e)
        {
            WinUpdateTestTextBox.Clear();

            Int32 _AuthResult = PerformAuthentication();

            //was authentication sucessful
            if (_AuthResult == 0)
            {
                WinUpdateTestTextBox.Text = "Sucessfully Authenticated!\n";
            }
            else
            {
                WinUpdateTestTextBox.Text = String.Format("Authentication Failed With SMB Code '{0}'", _AuthResult);

                //we cant do anything so break out and end the method.
                return;
            }//end of if-else (_AuthResult == 0)


            try
            {
                Type RemoteAgentInfoType = Type.GetTypeFromProgID("Microsoft.Update.AgentInfo", TargetTextBox.Text, true);
                WindowsUpdateAgentInfo RemoteAgentInfo = (WindowsUpdateAgentInfo)Activator.CreateInstance(RemoteAgentInfoType);

                String _AgentVersion = RemoteAgentInfo.GetInfo("ProductVersionString").ToString();

                WinUpdateTestTextBox.Text += String.Format("Windows Update Agent Version: '{0}'", _AgentVersion);
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("80070005") > -1)
                {
                    WinUpdateTestTextBox.Text += "Authentication Failed, Error 80070005\n";
                }
                else
                {
                    WinUpdateTestTextBox.Text += String.Format("Exception Thrown When Instantiating Windows Update DCOM!\nException:\n{0}", ex.Message);
                } //end of if-else if (ex.Message.IndexOf("80070005") > -1)
            }     //end of try-catch
        }         //end of method
Example #6
0
        private static bool IsWuavOutDated()
        {
            var xmlDoc = new XmlDocument(); //* create an xml document object.
            //xmlDoc.Load(Path.Combine(tempDir, xmlFileName));
            xmlDoc.LoadXml(WuRedistXml);

            var runningPlatform = (SystemInfo.IsWindows64Bit) ? "x64" : "x86";
            var xpath = String.Format(@"/WURedist/StandaloneRedist/architecture[@name=""{0}""]", runningPlatform);
            var node = xmlDoc.SelectSingleNode(xpath);

            try
            {
                var agent = new WindowsUpdateAgentInfo();
                //WindowsUpdateAgentInfoClass wuainfo = new WindowsUpdateAgentInfoClass();
                //int wualatestversion = (int)wuainfo.GetInfo("ApiMajorVersion");

                if (node != null)
                {
                    if (node.Attributes != null)
                    {
                        var latestVersion = node.Attributes["clientVersion"].Value.Trim();
                        var currentVersion = agent.GetInfo("ProductVersionString").ToString().Trim();

                        if (currentVersion.Equals(latestVersion))
                        {
                            Logger.Log("WUA is up to date. Current version: {0}, Minimun required version: {1}.",
                                       LogLevel.Info,
                                       currentVersion, latestVersion);
                            return false;
                        }

                        var latest = latestVersion.Split('.');
                        var current = currentVersion.Split('.');

                        for (var i = 0; i < 4; i++)
                        {
                            //Take into account that the latest version can "never" be less than the current version.
                            if (Convert.ToInt32(latest[i]) <= Convert.ToInt32(current[i])) continue;
                            Logger.Log("WUA is outdated. Current version: {0}, Minimun required version: {1}.", LogLevel.Error, currentVersion, latestVersion);
                            return true;
                        }
                        Logger.Log("WUA is up to date. Current version: {0}, Minimun required version: {1}.", LogLevel.Info, currentVersion, latestVersion);
                    }
                }
                return false;
            }
            catch (Exception e)
            {
                Logger.Log("Exception when attempting to check WUA version, Assuming out of Date.", LogLevel.Error);
                Logger.LogException(e);
                return true;
            }
        }
            private static bool IsWUAVOutDated()
            {
                XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object.
                //xmlDoc.Load(Path.Combine(tempDir, xmlFileName));
                xmlDoc.LoadXml(wuRedistXml);

                string runningPlatform = (SystemInfo.IsWindows64Bit) ? "x64" : "x86";
                string xpath = String.Format(@"/WURedist/StandaloneRedist/architecture[@name=""{0}""]", runningPlatform);
                XmlNode node = xmlDoc.SelectSingleNode(xpath);

                WindowsUpdateAgentInfo agent = new WindowsUpdateAgentInfo();

                string latestVersion = node.Attributes["clientVersion"].Value;
                string currentVersion = agent.GetInfo("ProductVersionString").ToString();

                if (currentVersion.Equals(latestVersion))
                {
                    AgentSettings.Log("WUA is up to date. Current version: {0}, Latest version: {1}.",
                        AgentLogLevel.Debug,
                        currentVersion, latestVersion);
                    return false;
                }
                else
                {
                    string[] latest = latestVersion.Split('.');
                    string[] current = currentVersion.Split('.');

                    for (int i = 0; i < 4; i++)
                    {
                        // Takea into account that the latest version can "never" be less than the current version.
                        if (Convert.ToInt32(latest[i]) > Convert.ToInt32(current[i]))
                        {
                            AgentSettings.Log("WUA is outdated. Current version: {0}, Latest version: {1}.",
                                AgentLogLevel.Error,
                                currentVersion, latestVersion);
                            return true;
                        }
                    }
                    AgentSettings.Log("WUA is up to date. Current version: {0}, Latest version: {1}.",
                        AgentLogLevel.Debug,
                        currentVersion, latestVersion);
                    return false;
                }
            }