/// <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(); }
/// <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); } }