Ejemplo n.º 1
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();
                }
            }
        }
Ejemplo n.º 2
0
        public static bool ChocoUpgrade(string pkgName, string displayName, bool verifyInstall, string searchName, string[] argumentList)
        {
            try
            {
                Console.Out.WriteLine("Verifying network connectivity before installing " + displayName);
                if (Network.TestInternetConnection() == true)
                {
                    Console.Out.WriteLine("Network connectivity confirmed...");

                    if ((verifyInstall) == true)
                    {
                        Console.Out.WriteLine("Checking for pre-existing installs...");
                        var x86VersionExists = ProgramInstaller.IsSoftwareInstalled(Architectures.X86, searchName);
                        var x64VersionExists = ProgramInstaller.IsSoftwareInstalled(Architectures.X64, searchName);
                        Console.Out.WriteLine("32-bit version found?: " + x86VersionExists);
                        Console.Out.WriteLine("64-bit version found?: " + x64VersionExists);
                    }

                    Console.Out.WriteLine("Installing " + displayName + "...");

                    string arguments = "";
                    foreach (string argument in argumentList)
                    {
                        arguments += " --" + argument;
                    }

                    SystemUtil.ExecuteCMDCommand("choco.exe upgrade " + pkgName + arguments); //" --force --y --ignorechecksum ");

                    if ((verifyInstall) == true)
                    {
                        Console.Out.WriteLine("Verifying install...");
                        var x86VersionExists = ProgramInstaller.IsSoftwareInstalled(Architectures.X86, searchName);
                        var x64VersionExists = ProgramInstaller.IsSoftwareInstalled(Architectures.X64, searchName);
                        Console.Out.WriteLine("32-bit version found?: " + x86VersionExists);
                        Console.Out.WriteLine("64-bit version found?: " + x64VersionExists);
                        if (x64VersionExists == true || x86VersionExists == true)
                        {
                            return(true);
                        }
                        else
                        {
                            Console.Out.WriteLine("[0] " + displayName + " installation failed... Rolling back...");
                            if (Network.TestInternetConnection() == false)
                            {
                                Console.Out.WriteLine("Failed to confirm network connectivity. if your host has connection, try: VMWare Toolbar -> Edit -> Virtual Network Editor -> Change Settings -> Restore Defaults. Then Restart");
                            }
                            return(false);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    Console.Out.WriteLine("Failed to confirm network connectivity. if your host has connection, try: VMWare Toolbar -> Edit -> Virtual Network Editor -> Change Settings -> Restore Defaults. Then Restart");
                    return(false);
                }
            }
            catch
            {
                Console.Out.WriteLine("[1] " + displayName + " installation failed... Rolling back...");
                return(false);
            }
        }