/// <summary> /// This does the driver\capsule installation and checks for the exit code to /// decide what to do next /// </summary> /// <param name="line"></param> /// <param name="installer"></param> /// <param name="installArgs"></param> internal static void Install_Inf(string line, string installer, string installArgs, int seedIndex) { Logger.FunctionEnter(); #region STRINGS AND THINGS string failureCause = "None"; string expectedDriverVersion = "N/A"; string beforeDriverStatus = "N/A"; string afterDriverStatus = "N/A"; bool deviceRuning = true; string errorCodeMessage; string installationExitCode; int TimeOut = 120; //string notInstalledExitCode = "0x800"; string couldNotFindInfToDelete = "0x80000000"; string ElementNotFoundCode = "0x490"; string DeviceCanNotStartCode = "0x10"; string InfFileAlteredCode = "0x80010000"; string NoMatchingDevice = "0xB7"; #endregion try { // starts the installation and checks for exit code // Logger.Comment("...trying to install now"); Logger.Comment("========================="); Logger.Comment(line); Logger.Comment(installer + installArgs); string runCommandinstallArgs = installArgs; Process process = Utilities.RunCommand(installer, runCommandinstallArgs, true); string errorMessage = process.StandardError.ReadToEnd(); string stdOutput = process.StandardOutput.ReadToEnd(); int exitCode = process.ExitCode; string exitCodeInHex = ConvertExitCodeToHex(exitCode); string tmpInstExitCode = "0x" + exitCodeInHex; if (tmpInstExitCode.Equals("0x1")) { tmpInstExitCode = "0x11100000"; } else if (tmpInstExitCode.Equals("0x0")) { tmpInstExitCode = "0x00000000"; } if (tmpInstExitCode.Length <= 5) { installationExitCode = tmpInstExitCode; } else { installationExitCode = tmpInstExitCode.Remove(5); } Console.WriteLine("installationExitCode : " + installationExitCode); // sets a timeout period to wait so the program doesn't get stuck waiting endlessly bool notTimeOut = process.WaitForExit(TimeOut); bool stopOnError = XMLReader.GetStopOnError(Program.InputTestFilePathBAK); if (stopOnError) { string lineContains = string.Empty; switch (lineContains) { case string noMatching when stdOutput.Contains(NoMatchingDevice): GetData.GetExitCode(installationExitCode, stdOutput, errorMessage); Logger.Comment("got exit code 0xB7, No Matching Device : " + line); Console.WriteLine("got exit code 0xB7, No Matching Device : " + line); Logger.Comment("Copy the driverstress log and DPINST.LOG to our folder..."); Utilities.CopyFile(@"C:\Windows\DPINST.LOG", Program.dpinstLog); Utilities.CopyFile(Program.dirName + @"\DriverCapsuleStressLog.txt", Program.resultsLogDir + @"\DriverSDriverCapsuleStressLogtressLog.txt"); Console.ReadKey(); Environment.Exit(13); break; case string elementNotFound when installationExitCode.Equals(ElementNotFoundCode): GetData.GetExitCode(installationExitCode, stdOutput, errorMessage); Logger.Comment("got exit code 49, try to re-install : " + line); Logger.Comment("Elemnt not found error, trying to uninstall a device that is not currently installed"); Console.WriteLine("got exit code 49, try to re-install : " + line); Console.WriteLine("Elemnt not found error, trying to uninstall a device that is not currently installed"); Logger.Comment("Copy the driverstress log and DPINST.LOG to our folder..."); Utilities.CopyFile(@"C:\Windows\DPINST.LOG", Program.dpinstLog); Utilities.CopyFile(Program.dirName + @"\DriverCapsuleStressLog.txt", Program.resultsLogDir + @"\DriverCapsuleStressLog.txt"); Console.ReadKey(); Environment.Exit(13); break; case string cannotStart when installationExitCode.Equals(DeviceCanNotStartCode): Logger.Comment("CODE 10 : device cannot start error for " + line); Console.WriteLine("CODE 10 : device cannot start error for " + line); Logger.Comment("Copy the driverstress log and DPINST.LOG to our folder..."); Utilities.CopyFile(@"C:\Windows\DPINST.LOG", Program.dpinstLog); Utilities.CopyFile(Program.dirName + @"\DriverCapsuleStressLog.txt", Program.resultsLogDir + @"\DriverCapsuleStressLog.txt"); Console.ReadKey(); Environment.Exit(13); break; case string couldNotFindInf when installationExitCode.Equals(couldNotFindInfToDelete): Logger.Comment("could Not Find Inf To Delete...what is up...check the logs later..."); Console.WriteLine("could Not Find Inf To Delete...what is up...check the logs later..."); Logger.Comment("Just move the driverstress log and DPINST.LOG to our folder..."); File.Move(@"C:\Windows\DPINST.LOG", Program.dpinstLog + ".ERR"); File.Move(Program.dirName + @"\DriverCapsuleStressLog.txt", Program.resultsLogDir + @"\DriverCapsuleStressLog-ERR.txt"); Environment.Exit(13); break; case string InfFileAltered when installationExitCode.Equals(InfFileAlteredCode): Logger.Comment("this was not installed because the inf file has been altered"); Console.WriteLine("this was not installed because the inf file has been altered"); Logger.Comment("Copy the driverstress log and DPINST.LOG to our folder..."); Utilities.CopyFile(@"C:\Windows\DPINST.LOG", Program.dpinstLog); Utilities.CopyFile(Program.dirName + @"\DriverCapsuleStressLog.txt", Program.resultsLogDir + @"\DriverCapsuleStressLog.txt"); Environment.Exit(13); break; default: if (notTimeOut == false) { failureCause = "Driver installation Timed-Out"; errorCodeMessage = string.Format(line + " Driver installation Timed-Out"); Logger.Comment(line + " Driver installation Failed due to Time-Out::: " + errorCodeMessage, expectedDriverVersion, DateTime.Now.ToString("MM/dd/yyyy H:mm:ss:fff"), beforeDriverStatus, afterDriverStatus, deviceRuning, failureCause); Logger.Comment("Copy the driverstress log and DPINST.LOG to our folder..."); Utilities.CopyFile(@"C:\Windows\DPINST.LOG", Program.dpinstLog); Utilities.CopyFile(Program.dirName + @"\DriverCapsuleStressLog.txt", Program.resultsLogDir + @"\DriverCapsuleStressLog.txt"); Console.ReadKey(); Environment.Exit(13); } break; } } process.Dispose(); } catch (Exception ex) { GetData.GetExceptionMessage(ex); } Logger.FunctionLeave(); }
/// <summary> /// just another check to be sure driver is installed /// this will run after there is a reboot so is mostly for validation of firmware installs /// GetData.IsInstalledAfterReboot(); /// </summary> internal static string IsInstalledAfterReboot(string line) { string result = "pass"; string returnCode = "pass"; try { // get the file attributes for file or directory FileAttributes attr = File.GetAttributes(line); // detect whether its a directory or file if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { foreach (string tmpPath in Directory.EnumerateFiles(line)) { if (tmpPath.EndsWith(".inf")) { line = tmpPath; } else { continue; } } } string TMPexpectedVersion = GetDriverVersion(line); string TMPinfName = Path.GetFileNameWithoutExtension(line); string TMPhardwareID = FirmwareInstallGetHID(line); string classGUID = GetClassGUID(line); int TMPinfListCount = XMLReader.GetInfsPathListCount(Program.InputTestFilePathBAK); int executionCount = XMLReader.GetExecutionCount(Program.InputTestFilePath); bool TMPisCapsule = CheckDriverIsFirmware(line, executionCount, TMPinfListCount); bool stopOnError = XMLReader.GetStopOnError(Program.InputTestFilePathBAK); if (TMPisCapsule) { string CapsuleDidInstall = GetDataFromReg.CheckRegCapsuleIsInstalled(TMPinfName, TMPhardwareID, TMPexpectedVersion, line); if (stopOnError.Equals(true)) { switch (returnCode) { case string failed when CapsuleDidInstall.Equals("unsuccessful"): returnCode = "unsuccessful registry code is 1 "; XMLErrorMessage(returnCode, line); break; case string InsufficientResources when CapsuleDidInstall.Equals("InsufficientResources"): returnCode = "InsufficientResources registry code is 2 "; XMLErrorMessage(returnCode, line); break; case string IncorrectVersion when CapsuleDidInstall.Equals("IncorrectVersion"): returnCode = "IncorrectVersion registry code is 3 "; XMLErrorMessage(returnCode, line); break; case string invalidImage when CapsuleDidInstall.Equals("invalidImage"): returnCode = "invalidImage registry code is 4 "; XMLErrorMessage(returnCode, line); break; case string authenticationERR when CapsuleDidInstall.Equals("authenticationERR"): returnCode = "authenticationERR registry code is 5 "; XMLErrorMessage(returnCode, line); break; case string ACnotConnected when CapsuleDidInstall.Equals("ACnotConnected"): returnCode = "ACnotConnected registry code is 6 "; XMLErrorMessage(returnCode, line); break; case string insufficientPower when CapsuleDidInstall.Equals("insufficientPower"): returnCode = "insufficientBatteryPower registry code is 7 "; XMLErrorMessage(returnCode, line); break; default: returnCode = "pass"; result = returnCode; Logger.Comment("checked the registry after reboot but this firmware installed correctly " + returnCode + " " + line); Console.WriteLine("checked the registry after reboot but this firmware installed correctly " + returnCode + " " + line); break; } } } return(result); } catch (Exception ex) { GetExceptionMessage(ex); return(result); } }