コード例 #1
0
        public void TestMethodDownloadUpdate()
        {
            Console.WriteLine("Check Update for SCCMCliCtr 1.0.3.9...");
            RZUpdater oRZSW   = new RZUpdater();
            var       oUpdate = oRZSW.CheckForUpdate("Adobe Acrobat Reader DC MUI", "19.021.20048", "Adobe Systems Incorporated");

            Console.WriteLine("found Version:" + oRZSW.SoftwareUpdate.SW.ProductVersion);
            Assert.IsNotNull(oUpdate, "Update detected successfully.");
            Assert.IsNotNull(oUpdate.SW.ContentID, "Update conatins ContentID");
            Console.Write("Downloading files..");
            bool bDLResult = oUpdate.Download().Result;

            Assert.IsTrue(bDLResult, "Files downloaded successfully.");
            if (bDLResult)
            {
                Console.WriteLine("..done.");
            }
            else
            {
                Console.WriteLine("download failed !!");
            }
        }
コード例 #2
0
        public void TestMethodDownloadUpdate()
        {
            Console.WriteLine("Check Update for SCCMCliCtr 1.0.3.9...");
            RZUpdater oRZSW   = new RZUpdater();
            var       oUpdate = oRZSW.CheckForUpdate("Client Center for Configuration Manager", "1.0.3.9", "Zander Tools");

            Console.WriteLine("found Version:" + oRZSW.SoftwareUpdate.SW.ProductVersion);
            Assert.IsNotNull(oUpdate, "Update detected successfully.");
            Assert.IsNotNull(oUpdate.SW.ContentID, "Update conatins ContentID");
            Console.Write("Downloading files..");
            bool bDLResult = oUpdate.Download().Result;

            Assert.IsTrue(bDLResult, "Files downloaded successfully.");
            if (bDLResult)
            {
                Console.WriteLine("..done.");
            }
            else
            {
                Console.WriteLine("download failed !!");
            }
        }
コード例 #3
0
        //public SCCMAgent oAgent;
        public CustomTools_SelfUpdate()
        {
            InitializeComponent();

            try
            {
                //Disbale SSL/TLS Errors
                System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                //Disable CRL Check
                System.Net.ServicePointManager.CheckCertificateRevocationList = false;

                //No check on first start...
                if (Properties.Settings.Default.LastUpdateCheck == new DateTime(2016, 1, 1))
                {
                    Properties.Settings.Default.LastUpdateCheck = DateTime.Now;
                    Properties.Settings.Default.Save(); //Fixed 25.5.2016
                    return;
                }


                if ((DateTime.Now - Properties.Settings.Default.LastUpdateCheck) >= new TimeSpan(2, 0, 0, 0) & Properties.Settings.Default.AutoUpdateEnabled)
                {
                    //btCheckUpdate.IsEnabled = SCCMCliCtr.Customization.CheckLicense();
                    string sVersion = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetEntryAssembly().Location).FileVersion;;

                    RZUpdater oRZUpdate = new RZUpdater();
                    var       oUpdate   = oRZUpdate.CheckForUpdate("Client Center for Configuration Manager", sVersion, "Zander Tools");

                    try
                    {
                        Properties.Settings.Default.LastUpdateCheck = DateTime.Now;
                        Properties.Settings.Default.Save();

                        if (IsUserAnAdmin())
                        {
                            //Delete an old RZUpdate.exe
                            if (File.Exists(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "RZUpdate.exe")))
                            {
                                try
                                {
                                    File.Delete(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "RZUpdate.exe"));
                                }
                                catch { }
                            }

                            if (oUpdate != null)
                            {
                                //Console.WriteLine("New Version: " + oUpdate.SW.ProductVersion);
                                ExtractSaveResource("AgentActionTools.RZUpdate.exe", Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "RZUpdate.exe"));

                                if (System.Windows.MessageBox.Show("Do you want to install Version: " + oUpdate.SW.ProductVersion, "Update available", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                                {
                                    try
                                    {
                                        Process.Start(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "RZUpdate.exe"), "\"Client Center for Configuration Manager\" \"" + sVersion + "\" \"Zander Tools\"");
                                        Process.GetCurrentProcess().Kill();
                                    }
                                    catch
                                    {
                                        System.Windows.MessageBox.Show("updated failed. Please run ClientCenter with Admin rights to install updates... ", "Failed", MessageBoxButton.OK, MessageBoxImage.Error);
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (oUpdate != null)
                            {
                                System.Windows.MessageBox.Show("An newer Version is available: " + oUpdate.SW.ProductVersion + ". You have to start ClientCenter as Admin to install the update", "Update available", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                        }
                    }
                    catch { }
                }
            }
            catch { }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: cs-student101/ruckzuck
        static void Main(string[] args)
        {
            //Get Proxy from IE
            WebRequest.DefaultWebProxy = WebRequest.GetSystemWebProxy();

            List <string> lArgs = args.ToList();

            if (lArgs.Contains("-?") | lArgs.Contains("/?") | lArgs.Count < 1)
            {
                Console.WriteLine("RuckZuck Update Tool (c) 2018 by Roger Zander");
                Console.WriteLine("Usage:");
                Console.WriteLine("Check and Update an existing Software : RZUpdate.exe \"<ProductName>\" \"<ProductVersion>\" [\"Manufacturer\"]");
                Console.WriteLine("Install a Software from Shortname : RZUpdate.exe \"<Shortname>\"[;\"<Shortname2>\"]");
                Console.WriteLine("Install a Software from XML-File: RZUpdate.exe \"<RZXML File.xml>\"");
                Console.WriteLine("Update all installed Software-Versions: RZUpdate.exe /Update");
                Console.WriteLine("");
                return;
            }

            RZRestAPI.sURL = Properties.Settings.Default.WebService;

            if (lArgs.Count == 1)
            {
                if (File.Exists(lArgs[0]))
                {
                    RZUpdater oRZSW = new RZUpdater(lArgs[0]);

                    Console.WriteLine(oRZSW.SoftwareUpdate.SW.ProductName + " " + oRZSW.SoftwareUpdate.SW.ProductVersion + " :");
                    Console.Write("Downloading...");
                    if (oRZSW.SoftwareUpdate.Download().Result)
                    {
                        Console.WriteLine("... done.");
                        Console.Write("Installing...");
                        if (oRZSW.SoftwareUpdate.Install(false, true).Result)
                        {
                            Console.WriteLine("... done.");
                        }
                        else
                        {
                            Console.WriteLine("... Error. The installation failed.");
                        }
                    }
                }
                else
                {
                    if (lArgs[0].ToLower() == "/update" | lArgs[0].ToLower() == "-update")
                    {
                        oUpdate = new RZUpdater();
                        oScan   = new RZScan(true, true);
                        Console.Write("Detecting updates...");
                        oScan.OnUpdScanCompleted += OScan_OnUpdScanCompleted;

                        while (bRunning)
                        {
                            System.Threading.Thread.Sleep(100);
                        }
                    }
                    else
                    {
                        foreach (string sArg in lArgs[0].Split(';'))
                        {
                            try
                            {
                                RZUpdater oRZSW = new RZUpdater();
                                oRZSW.SoftwareUpdate = new SWUpdate(sArg.Trim('"').Trim());

                                if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                                {
                                    Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                                    continue;
                                }


                                Console.WriteLine(oRZSW.SoftwareUpdate.SW.Manufacturer + " " + oRZSW.SoftwareUpdate.SW.ProductName + " " + oRZSW.SoftwareUpdate.SW.ProductVersion);
                                Console.Write("Downloading...");
                                foreach (string sPreReq in oRZSW.SoftwareUpdate.SW.PreRequisites)
                                {
                                    if (!string.IsNullOrEmpty(sPreReq))
                                    {
                                        RZUpdater oRZSWPreReq = new RZUpdater();
                                        oRZSWPreReq.SoftwareUpdate = new SWUpdate(sPreReq);
                                        Console.WriteLine();
                                        Console.Write("\tDownloading dependencies (" + oRZSWPreReq.SoftwareUpdate.SW.Shortname + ")...");
                                        if (oRZSWPreReq.SoftwareUpdate.Download().Result)
                                        {
                                            Console.WriteLine("... done.");
                                            Console.Write("\tInstalling dependencies (" + oRZSWPreReq.SoftwareUpdate.SW.Shortname + ")...");
                                            if (oRZSWPreReq.SoftwareUpdate.Install(false, true).Result)
                                            {
                                                Console.WriteLine("... done.");
                                            }
                                            else
                                            {
                                                Console.WriteLine("... Error. The installation failed.");
                                            }
                                        }
                                    }
                                }
                                if (oRZSW.SoftwareUpdate.Download().Result)
                                {
                                    Console.WriteLine("... done.");
                                    Console.Write("Installing...");
                                    if (oRZSW.SoftwareUpdate.Install(false, true).Result)
                                    {
                                        Console.WriteLine("... done.");
                                    }
                                    else
                                    {
                                        Console.WriteLine("... Error. The installation failed.");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Error: " + ex.Message);
                            }
                        }
                    }
                }
            }
            if (lArgs.Count == 2)
            {
                RZUpdater oRZUpdate = new RZUpdater();
                var       oUpdate   = oRZUpdate.CheckForUpdate(lArgs[0], lArgs[1]);
                if (oUpdate != null)
                {
                    Console.WriteLine("New Version: " + oUpdate.SW.ProductVersion);
                    Console.Write("Downloading...");

                    if (oUpdate.Download().Result)
                    {
                        Console.WriteLine("... done.");
                        Console.Write("Installing...");
                        if (oUpdate.Install(false, true).Result)
                        {
                            Console.WriteLine("... done.");
                        }
                        else
                        {
                            Console.WriteLine("... Error. The update installation failed.");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("No Update found...");
                }
            }

            if (lArgs.Count == 3)
            {
                RZUpdater oRZUpdate = new RZUpdater();
                var       oUpdate   = oRZUpdate.CheckForUpdate(lArgs[0], lArgs[1], lArgs[2]);
                if (oUpdate != null)
                {
                    Console.WriteLine("New Version: " + oUpdate.SW.ProductVersion);
                    Console.Write("Downloading...");

                    if (oUpdate.Download().Result)
                    {
                        Console.WriteLine("... done.");
                        Console.Write("Installing...");
                        if (oUpdate.Install(false, true).Result)
                        {
                            Console.WriteLine("... done.");
                        }
                        else
                        {
                            Console.WriteLine("... Error. The update installation failed.");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("No Update found...");
                }
            }

            System.Threading.Thread.Sleep(1000);
        }
コード例 #5
0
        private void btCheckUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //string sVersion = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
                string sVersion = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetEntryAssembly().Location).FileVersion;;

                RZUpdater oRZUpdate = new RZUpdater();
                var       oUpdate   = oRZUpdate.CheckForUpdate("Client Center for Configuration Manager", sVersion, "Zander Tools");

                try
                {
                    Properties.Settings.Default.LastUpdateCheck = DateTime.Now;
                    Properties.Settings.Default.Save();

                    if (IsUserAnAdmin())
                    {
                        if (oUpdate != null)
                        {
                            //Console.WriteLine("New Version: " + oUpdate.SW.ProductVersion);
                            ExtractSaveResource("AgentActionTools.RZUpdate.exe", Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "RZUpdate.exe"));

                            if (System.Windows.MessageBox.Show("Do you want to install Version: " + oUpdate.SW.ProductVersion, "Update available", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                            {
                                /*new Thread(() =>
                                 * {
                                 *  Thread.CurrentThread.IsBackground = true;
                                 *  if (oUpdate.Download())
                                 *  {
                                 *      if (oUpdate.Install(true))
                                 *      {
                                 *      }
                                 *      else
                                 *      {
                                 *          System.Windows.MessageBox.Show("Installation failed...");
                                 *      }
                                 *  }
                                 * }).Start();*/

                                Process.Start(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "RZUpdate.exe"), "SCCMCliCtr");
                                Process.GetCurrentProcess().Kill();
                            }
                        }
                        else
                        {
                            System.Windows.MessageBox.Show("No update available...", "Update", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                    else
                    {
                        if (oUpdate != null)
                        {
                            System.Windows.MessageBox.Show("An newer Version is available: " + oUpdate.SW.ProductVersion + ". You have to start ClientCenter as Admin to install the update", "Update available", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                }
                catch { }

                /*
                 * //Start only if updater.exe is not yet running...
                 * if (Process.GetProcessesByName("updater.exe").Count() == 0)
                 * {
                 *  Process.Start("updater.exe", "/checknow");
                 * }*/
            }
            catch { }
        }