Пример #1
0
        public static bool GetPendingReboot()
        {
            /*
             * Check "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\" if a subkey named "RebootPending" is present.
             * Check "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\" if a subkey named "RebootRequired" is present.
             * Check "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\" if a value "PendingFileRenameOperations" if present.
             * If any of these conditions are met, a reboot is required.
             */

            bool hasPendingReboot = false;

            RegistryKey cbsKey  = RegistryUtil.OpenSubKey(RegistryUtil.RegistryHives.LOCAL_MACHINE, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing");
            RegistryKey wuauKey = RegistryUtil.OpenSubKey(RegistryUtil.RegistryHives.LOCAL_MACHINE, @"SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update");
            RegistryKey smssKey = RegistryUtil.OpenSubKey(RegistryUtil.RegistryHives.LOCAL_MACHINE, @"SYSTEM\CurrentControlSet\Control\Session Manager");

            if (cbsKey.OpenSubKey("RebootPending") != null || wuauKey.OpenSubKey("RebootRequired") != null || smssKey.GetValue("PendingFileRenameOperations") != null)
            {
                hasPendingReboot = true;
            }

            return(hasPendingReboot);
        }
Пример #2
0
        public void TinybotSetup()
        {
            var newTinybotVersion = new Version(5, 5, 0, 0);

            if (SystemUtil.GetPendingReboot() == true)
            {
                Console.WriteLine("A reboot is pending. Will run TinybotInstaller at next logon...");
            }
            else
            {
                /*
                 *  Start-Transaction -RollbackPreference Error
                 */
                RegistryKey key =
                    RegistryUtil.OpenSubKey(
                        RegistryUtil.RegistryHives.LOCAL_MACHINE,
                        @"SYSTEM\CurrentControlSet\Services\Mouclass"
                        );

                key.SetValue("Start", 3, RegistryValueKind.DWord);

                DisableUserInput();

                Console.WriteLine("Beginning setup for TinybotW10 v" + newTinybotVersion.ToString());
                Console.WriteLine(@"Setup logs are located at: C:\Windows\Logs\TBSetup.log");

                RegistryKey winNTCurrentVersion =
                    RegistryUtil.OpenSubKey(
                        RegistryUtil.RegistryHives.LOCAL_MACHINE,
                        RegistryConstants.TINYBOT_VERSION_KEY_PATH
                        );

                string currentTBVersion =
                    string.Join(
                        "",
                        (string[])winNTCurrentVersion.GetValue(RegistryConstants.TINYBOT_VERSION_KEY)
                        );

                if (SetupProperties.CompatibleTinybotUpdgradeVersions.Contains(currentTBVersion) == true)
                {
                    string lineSeparator = "===============================================================================";
                    Console.WriteLine(@"Initializing setup. User input is disabled during this process. DO NOT SHUTDOWN OR RESTART! Script will automatically restart upon succesful completion. If setup hangs at any step longer than 30 minutes, please notify Trent! from RiD. Setup logs are located at: C:\Windows\Logs\TBSetup.log");
                    //Async-Open-MessageBox -Message ("Initializing setup. User input is disabled during this process. DO NOT SHUTDOWN OR RESTART! Script will automatically restart upon succesful completion. If setup hangs at any step longer than 30 minutes, please notify Trent! from RiD. Setup logs are located at: C:\Windows\Logs\TBSetup.log")
                    Console.WriteLine(lineSeparator);
                    //os.Setup();
                    Console.WriteLine(lineSeparator);
                    //osrs.Setup();
                    Console.WriteLine(lineSeparator);
                    //rs3.Setup();
                    Console.WriteLine(lineSeparator);
                    //Console.WriteLine("Verifying network connectivity before installing Chocolatey");
                    //if (Network.TestInternetConnection() == true)
                    //{
                    //Console.WriteLine("Network connectivity confirmed...");
                    //Chocolatey setup goes here
                    Console.WriteLine(lineSeparator);
                    //firefoxComponent.Setup();
                    Console.WriteLine(lineSeparator);
                    //winrarComponent.Setup();
                    Console.WriteLine(lineSeparator);
                    //teamViewerComponent.Setup();
                    Console.WriteLine(lineSeparator);
                    //javaX86Component.ComponentTasks.();
                    Console.WriteLine(lineSeparator);
                    //javaX64Component.Setup();
                    Console.WriteLine(lineSeparator);
                    //vmwware tools component here
                    Console.WriteLine(lineSeparator);

                    //TB Setup Cleanup component here

                    Console.WriteLine(lineSeparator);
                    currentTBVersion =
                        string.Join(
                            "",
                            (string[])winNTCurrentVersion.GetValue(
                                Path.Combine(
                                    RegistryConstants.HKLM_WINDOWSNTCURRENTVERSION_PATH,
                                    RegistryConstants.TINYBOT_VERSION_KEY
                                    )
                                )
                            );

                    if (SetupProperties.CompatibleTinybotUpdgradeVersions.Contains(currentTBVersion) == true)
                    {
                        Console.WriteLine("Setup complete. Updating Tinybot version to 4.4 R1...");
                        var tbVersionKey = RegistryUtil.OpenSubKey(RegistryUtil.RegistryHives.LOCAL_MACHINE, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\");
                        tbVersionKey.SetValue(RegistryConstants.TINYBOT_VERSION_KEY, newTinybotVersion);

                        if (tbVersionKey.GetValue(RegistryConstants.TINYBOT_VERSION_KEY).Equals(newTinybotVersion))
                        {
                            Console.WriteLine("Tinybot version updated successfully!");
                            Console.WriteLine("Rebooting to apply changes...");
                            CompleteTransaction();
                            EnableUserInput();
                            RestartComputer(0);
                        }
                        else
                        {
                            Console.WriteLine("Failed to update Tinybot version...");
                            UndoTransaction();
                            CancelSetup();
                        }
                    }
                    else
                    {
                        Console.WriteLine("Incompatible Tinybot version... Cannot perform setup... Please download the newest version from the 'How to Minimize Your Bot' thread.");
                        UndoTransaction();
                        CancelSetup();
                    }
                    //}
                    //else
                    //{
                    //    //Async-Open-MessageBox -Message ("Failed to confirm network connectivity. If your host has connection, try: VMWare Toolbar -> Edit -> Virtual Network Editor -> Change Settings -> Restore Defaults. Then Restart")
                    //    Console.WriteLine("Failed to confirm network connectivity. If your host has connection, try: VMWare Toolbar -> Edit -> Virtual Network Editor -> Change Settings -> Restore Defaults. Then Restart");
                    //    UndoTransaction();
                    //    CancelSetup();
                    //}
                }
                else
                {
                    Console.WriteLine("Incompatible Tinybot version... Cannot perform setup... Please download the newest version from the 'How to Minimize Your Bot' thread.");
                    //AsyncOpenMessageBoxMessage("Incompatible Tinybot version... Cannot perform setup... Please download the newest version from the 'How to Minimize Your Bot' thread.")
                    Console.WriteLine("Incompatible Tinybot version... Cannot perform setup... Please download the newest version from the 'How to Minimize Your Bot' thread.");
                    UndoTransaction();
                    CancelSetup();
                }
            }
        }