/// <summary>
        /// method to install firmware specifically
        /// </summary>
        /// <param name="line"></param>
        /// <param name="InputTestFilePathBAK"></param>
        /// <param name="installer"></param>
        /// <param name="executionCount"></param>
        /// <param name="dirName"></param>
        /// <param name="startChoice"></param>
        /// <param name="rollbackLine"></param>
        /// <param name="InputTestFilePath"></param>
        internal static void IfIsCapsule(int seedIndex, string infIndexListString, int?driverPathListCount, string infName, List <string> DriverPathList, string line, string InputTestFilePathBAK, string installer, int executionCount, string dirName, string startChoice, string rollbackLine, string InputTestFilePath)
        {
            try
            {
                //bool needRollBack = true;
                bool rebootRequired = true;
                Logger.FunctionEnter();
                string infFileContent = File.ReadAllText(line).ToUpper();
                string infDir         = Path.GetDirectoryName(line);
                Logger.Comment("IfIsCapsule isCapsule infName " + infName);
                string expectedDriverVersion = GetData.GetDriverVersion(line);
                Logger.Comment("IfIsCapsule From RegCheck before IF : " + expectedDriverVersion);
                string infNameToTest      = Path.GetFileNameWithoutExtension(line);
                string expectedDriverDate = GetData.GetDriverDate(line);
                string infPath            = Path.GetDirectoryName(line);
                int    infListCount       = XMLReader.GetInfsPathListCount(Program.InputTestFilePathBAK);

                string friendlyDriverName = XMLReader.GetFriendlyDriverName(InputTestFilePath, line);
                string hardwareID         = GetData.FirmwareInstallGetHID(line);
                bool   isInstalled        = CheckWhatInstalled.CheckInstalled(line, hardwareID, friendlyDriverName, infNameToTest, expectedDriverVersion, expectedDriverDate);

                if (isInstalled)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("-------------------------------------------------------------");
                    Console.WriteLine("THIS FIRMWARE VERSION IS CURRENTLY INSTALLED ROLLBACK NOW....");
                    Console.WriteLine("-------------------------------------------------------------");
                    Console.ForegroundColor = ConsoleColor.White;
                    GetData.IfWillNeedRollBack(line);
                    driverPathListCount--;
                    Logger.Comment("this will now begin to ROLLBACK : " + infName);
                    SafeNativeMethods.RollbackInstall(seedIndex, line, infName, infFileContent, hardwareID, rebootRequired = true, InputTestFilePath);
                    RebootAndContinue.RebootCmd(true);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("-------------------------------------------------------------");
                    Console.WriteLine("THIS FIRMWARE VERSION WAS NOT INSTALLED YET INSTALLING NOW...");
                    Console.WriteLine("-------------------------------------------------------------");
                    Console.ForegroundColor = ConsoleColor.White;
                    hardwareID = GetData.FirmwareInstallGetHID(line);
                    string installArgs = " /C /A /Q /SE /F /PATH " + infDir;
                    Logger.Comment("IfIsCapsule installArgsChoice  is FALSE installArgs " + installArgs);
                    driverPathListCount--;
                    Logger.Comment("this will now Install : " + infName);
                    installArgs = " /C /A /Q /SE /F /PATH " + infDir;
                    RegCheck.CreatePolicyRegKeyAndSetValue(hardwareID, rebootRequired);
                    RebootAndContinue.SetStartUpRegistry(Program.reStartBAT);
                    Logger.Comment("installArgs from FirmwareInstall : " + installArgs);
                    SafeNativeMethods.Install_Inf(line, installer, installArgs, seedIndex);
                }
            }
            catch (Exception ex)
            {
                GetData.GetExceptionMessage(ex);
            }
            Logger.FunctionLeave();
        }
        /// <summary>
        /// Where most of the work is done to decide what to do then call the methods to do so
        /// </summary>
        /// <param name="installer"></param>
        /// <param name=""></param>
        /// <param name="dirName"></param>
        /// <param name="startChoice"></param>
        internal static void StartStress(string InputTestFilePath, string installer, string dirName, string startChoice, string rollbackLine, int infListCount = 0)
        {
            try
            {
                Logger.FunctionEnter();

                if (!File.Exists(dirName + @"\debugEnabled.txt"))
                {
                    Logger.Comment("enabled WinDebugMode we must reboot...");
                    Thread.Sleep(1000);
                    RebootAndContinue.EnableWinDebugMode();
                }
                if (RegCheck.IsRebootPending())
                {
                    Logger.Comment("there is a pending reboot...");
                    Thread.Sleep(3000);
                    RebootAndContinue.RebootCmd(true);
                }
                if (GetData.CheckCrashDumpOccurred())
                {
                    Logger.Comment("Looks like we found a crashdump check it out after reboot...");
                    Thread.Sleep(1000);
                    RebootAndContinue.RebootCmd(true);
                }

                GetData.CreateIfMissing(Program.resultsLogDir);
                int executionCount = XMLReader.GetExecutionCount(InputTestFilePath);

                string InputTestFilePathBAK = dirName + @"\DriverCapsuleStress.xml.BAK";
                if (!File.Exists(InputTestFilePathBAK))
                {
                    Utilities.CopyFile(InputTestFilePath, InputTestFilePathBAK);
                }

                infListCount = XMLReader.GetInfsPathListCount(Program.InputTestFilePathBAK);

                string infIndexListString = XMLReader.GetSeed(Program.InputTestFilePathBAK);
                if (string.IsNullOrEmpty(infIndexListString))
                {
                    RewriteXMLContinue(executionCount, infListCount);
                }
                Logger.FunctionLeave();
            }
            catch (Exception ex)
            {
                GetData.GetExceptionMessage(ex);
            }
        }
        /// <summary>
        /// executes the stress in the order given by the list that was created
        /// only changed during execution when it finds firmware or the users choice to start first
        /// also groups firmware if chosen at runtime to install all firmware and reboot only once rather
        /// than rebooting for each firmware install seperately
        /// </summary>
        /// <param name="randomize"></param>
        /// <param name="executionCount"></param>
        /// <param name="dirName"></param>
        /// <param name="InputTestFilePath"></param>
        /// <param name="supportFolderLOC"></param>
        /// <param name="seedFilePath"></param>
        /// <param name="startChoice"></param>
        internal static void ExecuteTheList(bool randomize, int executionCount, string startChoice)
        {
            Process devMgr = new Process();

            devMgr.StartInfo.FileName  = @"C:\Windows\System32\mmc.exe";
            devMgr.StartInfo.Arguments = "devmgmt.msc";
            devMgr.Start();

            try
            {
                List <string> DriverPathList = GetData.GetInfPathsList(Program.dirName);
                CheckWhatInstalled.CheckInstalledCSV();

                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.WriteLine("Waiting 3 seconds to be sure device is up and running...");
                Console.ForegroundColor = ConsoleColor.White;
                Thread.Sleep(3000);
                if (RegCheck.IsRebootPending())
                {
                    Logger.Comment("there is a pending reboot...");
                    RebootAndContinue.RebootCmd(true);
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Checking for last installed...");
                Console.WriteLine("if it exists we'll check that it was successfull then...");
                Console.WriteLine("... ExecuteTheList...");
                Console.ForegroundColor = ConsoleColor.White;

                // check if lastInstalled in the XML was successfully installed post-reboot
                string tmpLine = XMLReader.GetLastInstalled();
                if (string.IsNullOrEmpty(tmpLine))
                {
                    Console.WriteLine("no previous driver installed to check just yet...");
                }

                else
                {
                    string installCheck = GetData.IsInstalledAfterReboot(tmpLine);
                    switch (installCheck)
                    {
                    case string unsuccessful when installCheck.Equals("unsuccessful"):
                        DoThisIfFailedPostReboot();

                        break;

                    case string InsufficientResources when installCheck.Equals("InsufficientResources"):
                        DoThisIfFailedPostReboot();

                        break;

                    case string IncorrectVersion when installCheck.Equals("IncorrectVersion"):
                        DoThisIfFailedPostReboot();

                        break;

                    case string invalidImage when installCheck.Equals("invalidImage"):
                        DoThisIfFailedPostReboot();

                        break;

                    case string authenticationERR when installCheck.Equals("authenticationERR"):
                        DoThisIfFailedPostReboot();

                        break;

                    case string ACnotConnected when installCheck.Equals("ACnotConnected"):
                        DoThisIfFailedPostReboot();

                        break;

                    case string insufficientPower when installCheck.Equals("insufficientPower"):
                        DoThisIfFailedPostReboot();

                        break;

                    default:
                        installCheck.Equals("pass");
                        break;
                    }
                }


                // making sure there is a driver path to test in the XML file
                // if they have all been removed they are all done and we need to rewrite the XML
                int    infListCount       = XMLReader.GetInfsPathListCount(Program.InputTestFilePathBAK);
                string infIndexListString = XMLReader.GetSeed(Program.InputTestFilePathBAK);
                if (string.IsNullOrEmpty(infIndexListString))
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("infListCount = " + infListCount);
                    Console.ForegroundColor = ConsoleColor.White;
                    executionCount          = XMLReader.GetExecutionCount(Program.InputTestFilePath);
                    DriverStressInit.RewriteXMLContinue(executionCount, infListCount);
                }

                // double check the current executin count in the XML to be sure we proceed correctly
                int TMPexecutionCount = XMLReader.GetExecutionCount(Program.InputTestFilePath);
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("executionCount : " + TMPexecutionCount);
                Console.WriteLine("----------------------------------------------------------");
                Console.WriteLine("time to check the executionCount and decide what to do...");
                Console.WriteLine("...waiting 10 seconds for Windows to catch up to me......");
                Console.WriteLine("----------------------------------------------------------");
                Console.ForegroundColor = ConsoleColor.White;
                Thread.Sleep(10000);

                // if the execution count is now zero it is time to collect logs etc
                if (TMPexecutionCount == 0)
                {
                    Console.WriteLine("waiting before continue to see if this is where it is dying....sometimes...");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("-----------------------------------------");
                    Console.WriteLine("at this point...I think I am done...am I?");
                    Console.WriteLine("-----------------------------------------");
                    Console.ForegroundColor = ConsoleColor.White;
                    ParseForResults.ParseFromdpinstLog(@"C:\Windows\DPINST.LOG");
                    File.Create(Program.dirName + @"\DONE.TXT");
                    CheckWhatInstalled.CheckInstalledCSV();
                    Logger.Comment("Copy the the driverstress log and DPINST.LOG to our folder...");
                    Utilities.CopyFile(@"C:\Windows\DPINST.LOG", Program.dpinstLog);
                    Utilities.CopyFile(Program.InputTestFilePathBAK, Program.resultsLogDir + @"\DriverCapsuleStress.xml.BAK");
                    Utilities.CopyFile(Program.dirName + @"\DriverCapsuleStressLog.txt", Program.resultsLogDir + @"\DriverCapsuleStressLog.txt");
                    Thread.Sleep(5000);
                    Console.WriteLine("Everything should be completed including copying logs to the Reults folder on the desktop");
                    // is the WTT service stopped.
                    StartStopServices.StartService("wttsvc");
                    Logger.FunctionLeave();
                }

                while (TMPexecutionCount >= 1)
                {
                    string    seedStr = XMLReader.GetSeed(Program.InputTestFilePathBAK);
                    XDocument xdoc    = XDocument.Load(Program.InputTestFilePath);
                    infIndexListString = XMLReader.GetSeed(Program.InputTestFilePathBAK);
                    Console.WriteLine("infIndexListString = " + infIndexListString);

                    if (randomize)
                    {
                        // if random is set to true this will take the list of index' for each INF
                        // into a list and shuffle the numbers out of order randomly using random seed
                        // then run through the list in that new order
                        // this will be done uniquely each time through the list for the executionCount
                        executionCount = XMLReader.GetExecutionCount(Program.InputTestFilePath);
                        foreach (int seedIndex in infIndexListString.Split(',').Select(Int32.Parse).ToList <int>())
                        {
                            if (seedIndex == 0)
                            {
                                break;
                            }
                            if (RegCheck.IsRebootPending())
                            {
                                Logger.Comment("there is a pending reboot...");
                                Thread.Sleep(3000);
                                RebootAndContinue.RebootCmd(true);
                            }
                            string index = Convert.ToString(seedIndex);
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Current infIndex to be tested : " + index);
                            Console.ForegroundColor = ConsoleColor.White;
                            DriverPathList          = GetData.GetInfPathsList(Program.dirName);

                            string line = XMLReader.FromINFIndex(infListCount, Program.InputTestFilePath, seedIndex, executionCount).ToLower();
                            if (string.IsNullOrEmpty(line))
                            {
                                XMLWriter.UpdateSeedXML(seedIndex);
                                break;
                            }
                            string infName = Path.GetFileName(line);
                            GetData.CreateIfMissing(Program.resultsLogDir);

                            bool isCapsule = GetData.CheckDriverIsFirmware(line, executionCount, infListCount);
                            switch (isCapsule)
                            {
                            case true:
                                Logger.Comment("this is firmware treat it as such and reboot or rollback\reboot...");
                                infListCount--;
                                CapsuleOrNotInstallCalls.IfIsCapsule(seedIndex, infIndexListString, infListCount, infName, DriverPathList, line, Program.InputTestFilePathBAK, Program.installer, executionCount, Program.dirName, Program.startChoice, Program.rollbackLine, Program.InputTestFilePath);
                                break;

                            default:
                                Logger.Comment("this is NOT firmware check for reboot afer installed");
                                infListCount--;
                                CapsuleOrNotInstallCalls.IsNotCapsule(seedIndex, infIndexListString, infListCount, infName, DriverPathList, line, Program.InputTestFilePathBAK, Program.installer, executionCount, Program.dirName, Program.startChoice, Program.rollbackLine, Program.InputTestFilePath);
                                break;
                            }
                        }
                        RebootAndContinue.RebootCmd(true);
                    }

                    else
                    {
                        // straight through the list 1-# accounting for other parameters below
                        // groupFirmware or not as well as user choice first
                        string testIsStartChoice = GetData.GetTestFirst(Program.InputTestFilePath);
                        if (testIsStartChoice.Equals("none") & (Directory.EnumerateDirectories(Program.dirName, "uefi")).Equals(true))
                        {
                            XMLWriter.SetTestFirst("uefi");
                        }
                        else if (testIsStartChoice.Equals("none") & (Directory.EnumerateDirectories(Program.dirName, "sam")).Equals(true))
                        {
                            XMLWriter.SetTestFirst("sam");
                        }
                        else
                        {
                            testIsStartChoice = "none";
                        }
                        // add ability to group install all firmware together with only one reboot
                        // in this case the firmware would all install individually but have only one reboot
                        // user should see each different color bar during reboot\install of all firmware
                        bool groupFirmware = XMLReader.GetGroupFirmware(Program.InputTestFilePathBAK);
                        int  capListCount  = 0;

                        if (groupFirmware)
                        {
                            executionCount = XMLReader.GetExecutionCount(Program.InputTestFilePath);
                            foreach (int seedIndex in infIndexListString.Split(',').Select(Int32.Parse).ToList <int>())
                            {
                                Console.WriteLine("if (groupFirmware) - seedIndex : " + seedIndex);
                                string line = XMLReader.FromINFIndex(infListCount, Program.InputTestFilePath, seedIndex, executionCount).ToLower();
                                if (string.IsNullOrEmpty(line))
                                {
                                    XMLWriter.UpdateSeedXML(seedIndex);
                                    break;
                                }
                                Console.WriteLine("if (groupFirmware) - line : " + line);
                                bool isCapsule = GetData.CheckDriverIsFirmware(line, executionCount, infListCount);

                                if (isCapsule)
                                {
                                    capListCount++;
                                    capList.Add(line);
                                }
                                else
                                {
                                    continue;
                                }
                            }

                            while (capListCount > 1)
                            {
                                // if this is set to true this will get the firmware in the list to install
                                // install each one and reboot at the end rather than rebooting for each install
                                // replicating more of what a user might see at home when getting more than one
                                // firmware update from WU
                                foreach (string groupedFirmware in capList)
                                {
                                    {
                                        string seedIndexSTR = XMLReader.IndexFromINF(Program.InputTestFilePath, groupedFirmware);
                                        int    seedIndex    = Convert.ToInt32(seedIndexSTR);
                                        XMLWriter.RemoveXMLElemnt(Program.InputTestFilePath, groupedFirmware, seedIndex);
                                        Console.WriteLine("seedIndex : " + seedIndex);

                                        string friendlyDriverName    = XMLReader.GetFriendlyDriverName(Program.InputTestFilePath, groupedFirmware);
                                        string hardwareID            = GetData.FirmwareInstallGetHID(groupedFirmware);
                                        string expectedDriverVersion = GetData.GetDriverVersion(groupedFirmware);
                                        Logger.Comment("IfIsCapsule From RegCheck before IF : " + expectedDriverVersion);
                                        string infNameToTest      = Path.GetFileNameWithoutExtension(groupedFirmware);
                                        string expectedDriverDate = GetData.GetDriverDate(groupedFirmware);
                                        bool   isInstalled        = CheckWhatInstalled.CheckInstalled(groupedFirmware, hardwareID, friendlyDriverName, infNameToTest, expectedDriverVersion, expectedDriverDate);

                                        switch (isInstalled)
                                        {
                                        case true:
                                            string infFileContent = File.ReadAllText(groupedFirmware).ToUpper();
                                            string infName        = Path.GetFileNameWithoutExtension(groupedFirmware);
                                            SafeNativeMethods.RollbackInstall(seedIndex, groupedFirmware, infName, infFileContent, hardwareID, rebootRequired = true, Program.InputTestFilePath);
                                            break;

                                        case false:
                                            string groupedFirmwareDIR = Path.GetDirectoryName(groupedFirmware);
                                            string installArgs        = " /C /A /Q /SE /F /PATH " + groupedFirmwareDIR;
                                            SafeNativeMethods.Install_Inf(groupedFirmware, Program.installer, installArgs, seedIndex);
                                            break;
                                        }
                                    }
                                    capListCount--;
                                }
                                RebootAndContinue.RebootCmd(true);
                            }
                        }

                        executionCount = XMLReader.GetExecutionCount(Program.InputTestFilePath);
                        foreach (int seedIndex in infIndexListString.Split(',').Select(Int32.Parse).ToList <int>())
                        {
                            if (seedIndex == 0)
                            {
                                break;
                            }
                            string index = Convert.ToString(seedIndex);
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Current infIndex to be tested : " + index);
                            Console.ForegroundColor = ConsoleColor.White;
                            if (index.Equals(null))
                            {
                                continue;
                            }
                            GetData.CreateIfMissing(Program.resultsLogDir);

                            string line = XMLReader.FromINFIndex(infListCount, Program.InputTestFilePath, seedIndex, executionCount).ToLower();
                            if (string.IsNullOrEmpty(line))
                            {
                                XMLWriter.UpdateSeedXML(seedIndex);
                                break;
                            }
                            string infName = Path.GetFileNameWithoutExtension(line);
                            testIsStartChoice = GetData.GetTestFirst(Program.InputTestFilePath);
                            string testInfName = infName.ToLower();
                            infIndexListString = XMLReader.GetSeed(Program.InputTestFilePathBAK);

                            // the tool will skip to here if none of the other above are met
                            // then looking for a choice set to install first from the list
                            // only works when random is set to False
                            if (line.Contains(testIsStartChoice.ToLower()))
                            {
                                Logger.Comment("This is the start first choice : " + line);
                                bool isCapsule = GetData.CheckDriverIsFirmware(line, executionCount, infListCount);

                                switch (isCapsule)
                                {
                                case true:
                                    infListCount--;
                                    Logger.Comment("re-add the reg key to start post reboot...");
                                    CapsuleOrNotInstallCalls.IfIsCapsule(seedIndex, infIndexListString, infListCount, infName, DriverPathList, line, Program.InputTestFilePathBAK, Program.installer, executionCount, Program.dirName, Program.startChoice, Program.rollbackLine, Program.InputTestFilePath);
                                    break;

                                default:
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("NOT MATCHING to the startChoice");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    infListCount--;
                                    CapsuleOrNotInstallCalls.IsNotCapsule(seedIndex, infIndexListString, infListCount, infName, DriverPathList, line, Program.InputTestFilePathBAK, Program.installer, executionCount, Program.dirName, Program.startChoice, Program.rollbackLine, Program.InputTestFilePath);
                                    break;
                                }
                            }
                        }

                        infIndexListString = XMLReader.GetSeed(Program.InputTestFilePathBAK);
                        foreach (int seedIndex in infIndexListString.Split(',').Select(Int32.Parse).ToList <int>())
                        {
                            if (seedIndex == 0)
                            {
                                break;
                            }
                            string index = Convert.ToString(seedIndex);
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Current infIndex to be tested : " + index);
                            Console.ForegroundColor = ConsoleColor.White;

                            string indexString = Convert.ToString(index);
                            if (index.Equals(null))
                            {
                                continue;
                            }

                            string line = XMLReader.FromINFIndex(infListCount, Program.InputTestFilePath, seedIndex, executionCount).ToLower();
                            if (string.IsNullOrEmpty(line))
                            {
                                XMLWriter.UpdateSeedXML(seedIndex);
                                break;
                            }
                            bool   isCapsule = GetData.CheckDriverIsFirmware(line, executionCount, infListCount);
                            string infName   = Path.GetFileName(line);
                            testIsStartChoice = GetData.GetTestFirst(Program.InputTestFilePath);

                            switch (isCapsule)
                            {
                            case true:
                                Logger.Comment("this is firmware and will need to reboot...");
                                infListCount--;
                                CapsuleOrNotInstallCalls.IfIsCapsule(seedIndex, infIndexListString, infListCount, infName, DriverPathList, line, Program.InputTestFilePathBAK, Program.installer, executionCount, Program.dirName, Program.startChoice, Program.rollbackLine, Program.InputTestFilePath);
                                break;

                            default:
                                Logger.Comment("THIS IS NOT FIRMWARE...");
                                infListCount--;
                                CapsuleOrNotInstallCalls.IsNotCapsule(seedIndex, infIndexListString, infListCount, infName, DriverPathList, line, Program.InputTestFilePathBAK, Program.installer, executionCount, Program.dirName, Program.startChoice, Program.rollbackLine, Program.InputTestFilePath);
                                break;
                            }
                        }
                        RebootAndContinue.RebootCmd(true);
                    }
                    executionCount--;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("executionCount :: " + executionCount);
                    Console.WriteLine("outside of the while loop");
                    Console.WriteLine("should be getting smaller correctly");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }

            catch (Exception ex)
            {
                GetData.GetExceptionMessage(ex);
            }
        }
示例#4
0
        /// <summary>
        /// this is called when installing firmware to perform the extra actions needed such as regkey writes and reboot
        /// </summary>
        /// <param name="infName"></param>
        /// <param name="infFileContent"></param>
        /// <param name="hardwareID"></param>
        /// <param name="rebootRequired"></param>
        /// <param name="rollBackLine"></param>
        /// <param name="installer"></param>
        /// <param name="installArgs"></param>
        /// <param name="InputTestFilePath"></param>
        internal static void RollbackInstall(int seedIndex, string line, string infName, string infFileContent, string hardwareID, bool rebootRequired, string InputTestFilePath)
        {
            Logger.FunctionEnter();
            string installArgs;
            string fullRollBackFile   = string.Empty;
            string fullRollBackDIR    = string.Empty;
            string fullRollBackDIRdir = string.Empty;

            try
            {
                XMLWriter.RemoveXMLElemnt(Program.InputTestFilePath, line, seedIndex);
                RegCheck.CreatePolicyRegKeyAndSetValue(hardwareID, rebootRequired.Equals(true));

                fullRollBackDIR = GetData.CheckRollbacksExist(line, infName);

                if (string.IsNullOrEmpty(fullRollBackDIR))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("should i even be trying to rollback at all???");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    fullRollBackDIRdir = Path.GetDirectoryName(fullRollBackDIR);
                }

                installArgs = " /C /U " + line + " /Q /D";
                string tmpfileName = string.Empty;
                string tmpVersion  = GetData.GetDriverVersion(line);
                var    binsList    = Directory.EnumerateFiles(@"C:\Windows\Firmware\");
                foreach (string binFileToDelete in binsList)
                {
                    tmpfileName = Path.GetFileNameWithoutExtension(binFileToDelete);
                    tmpVersion  = tmpVersion.TrimEnd('0').TrimEnd('0').TrimEnd('.');
                    if (Regex.Match(tmpfileName, tmpVersion).Success)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("binFileToDelete exists : " + tmpfileName);
                        File.Delete(tmpfileName);
                        Console.ForegroundColor = ConsoleColor.White;
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                Install_Inf(line, Program.installer, installArgs, seedIndex);
                Logger.Comment("Uninstall Operation should be complete: " + line);
                installArgs = " /C /A /Q /SE /F /PATH " + fullRollBackDIRdir;
                Logger.Comment("start rollback...");
                XMLWriter.SetLastInstalled(fullRollBackDIR);
                Install_Inf(line, Program.installer, installArgs, seedIndex);
                string classGUID             = GetData.GetClassGUID(line);
                string expectedDriverVersion = GetData.GetDriverVersion(line);
                GetDataFromReg.GetOEMinfNameFromReg(infName, hardwareID, classGUID);
                if (RegCheck.IsRebootPending())
                {
                    Logger.Comment("there is a pending reboot...");
                    RebootAndContinue.RebootCmd(true);
                }
            }
            catch (Exception ex)
            {
                GetData.GetExceptionMessage(ex);
            }
            Logger.FunctionLeave();
        }
示例#5
0
        /// <summary>
        /// firmware or regular driver will still call this to do the actual installation
        /// </summary>
        /// <param name="infName"></param>
        /// <param name="line"></param>
        /// <param name="installer"></param>
        /// <param name="installArgs"></param>
        /// <param name="InputTestFilePath"></param>
        /// <param name="rebootRequired"></param>
        /// <param name="hardwareID"></param>
        /// SafeNativeMethods.InstallUninstallCall(seedIndex, rebootRequired, infName, line, installer, InputTestFilePath);
        internal static void InstallUninstallCall(int seedIndex, bool rebootRequired, string infName, string line, string installer, string InputTestFilePath)
        {
            try
            {
                Logger.FunctionEnter();
                string expectedDriverVersion = GetData.GetDriverVersion(line);
                string infNameToTest         = Path.GetFileNameWithoutExtension(line);
                string expectedDriverDate    = GetData.GetDriverDate(line);
                string infPath = Path.GetDirectoryName(line);
                string installArgs;
                string friendlyDriverName = XMLReader.GetFriendlyDriverName(InputTestFilePath, line);
                Console.WriteLine(line + " and " + seedIndex);
                Console.WriteLine("RemoveXMLElement now");
                XMLWriter.RemoveXMLElemnt(Program.InputTestFilePath, line, seedIndex);
                Console.WriteLine("check the xml please..");
                string hardwareID  = GetData.FirmwareInstallGetHID(line);
                bool   isInstalled = CheckWhatInstalled.CheckInstalled(line, hardwareID, friendlyDriverName, infNameToTest, expectedDriverVersion, expectedDriverDate);
                if (isInstalled)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("----------------------------------------------------------");
                    Console.WriteLine("THIS PnP DRIVER VERSION IS INSTALLED UN-INSTALLING NOW....");
                    Console.WriteLine(infName);
                    Console.WriteLine("----------------------------------------------------------");
                    Console.ForegroundColor = ConsoleColor.White;

                    Logger.Comment("rebootRequired is showing as : " + rebootRequired);
                    installArgs = " /C /U " + line + " /Q /D";
                    Install_Inf(line, installer, installArgs, seedIndex);
                    Logger.Comment("Operation should be complete: " + line);

                    string classGUID = GetData.GetClassGUID(line);
                    GetDataFromReg.GetOEMinfNameFromReg(infName, hardwareID, classGUID);

                    if (RegCheck.IsRebootPending())
                    {
                        Logger.Comment("there is a pending reboot...");
                        RebootAndContinue.RebootCmd(true);
                    }
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("---------------------------------------------------------------");
                    Console.WriteLine("THIS PnP DRIVER VERSION WAS NOT INSTALLED YET INSTALLING NOW...");
                    Console.WriteLine(infName);
                    Console.WriteLine("---------------------------------------------------------------");
                    Console.ForegroundColor = ConsoleColor.White;

                    Logger.Comment("rebootRequired is showing as : " + rebootRequired);
                    installArgs = " /C /A /Q /SE /F /PATH " + infPath;
                    Install_Inf(line, installer, installArgs, seedIndex);
                    string classGUID = GetData.GetClassGUID(line);
                    XMLWriter.SetLastInstalled(line);

                    //can we check registry simiarly to firmware for PnP drivers?
                    Logger.Comment("Operation should be complete: " + line);

                    if (RegCheck.IsRebootPending())
                    {
                        Logger.Comment("there is a pending reboot...");
                        RebootAndContinue.RebootCmd(true);
                    }
                }
                Logger.FunctionLeave();
            }
            catch (Exception ex)
            {
                GetData.GetExceptionMessage(ex);
            }
        }