antmar904 Posted April 25, 2016 Posted April 25, 2016 (edited) Hi, I am trying to read the log file for the Internet Explorer 11 installation located @ C:\Windows\IE_main.log and search for the setup exit code. The line that I am trying to get the setup exit code always begins with "Setup exit code:" then the exit code and some text. Exp: Setup exit code: 0x00000BC2 (3010) - Installation Succeeded. Reboot required. OR Setup exit code: 0x00009C59 (40025) - The neutral cab failed to install. How would I get the contents of the whole line that states the "Setup exit code"? This is what I have so far but is not working #include <FileConstants.au3> #include <MsgBoxConstants.au3> Local $Results = "unknown" Local $IE11Log = ("C:\Temp\IE_main.log") ;Test log file location Local $hFileOpen = FileOpen($IE11Log, 0) Local $Content = FileRead($hFileOpen) If StringInStr($Content, "Setup exit code:") Then Local $String = StringRegExp($Content, "(?i)Setup exit code:") If IsArray($String) Then $Results = $String[0] MsgBox("", "Results", $Results) Edited April 25, 2016 by antmar904
Trong Posted April 25, 2016 Posted April 25, 2016 Try my bad script: Local $Results = "unknown" Local $IE11Log = "C:\Temp\IE_main.log" Local $Content = FileReadToArray($IE11Log) If IsArray($Content) Then For $i = 0 To UBound($Content) - 1 If StringInStr($Content[$i], "Setup exit code:") Then $Results = StringReplace($Content[$i], "Setup exit code:", "") MsgBox(0, "Results", $Results) EndIf Next EndIf Regards,
mikell Posted April 25, 2016 Posted April 25, 2016 Local $aString = StringRegExp($Content, "(?i)Setup exit code:\N+", 3) If IsArray($aString) Then $Results = $aString[0] MsgBox("", "Results", $Results)
antmar904 Posted April 26, 2016 Author Posted April 26, 2016 (edited) @wayfarer nothing is returned, no msgbox pops up. @mikell I'm still getting a msgbox with results "unknown" I've attached a sample of the IE11 install log file and would like to caputre that line that contains "Setup exit code:" IE11_main.log Edited April 26, 2016 by antmar904
mikell Posted April 26, 2016 Posted April 26, 2016 antmar904, Using the "IE11_main.log" you posted, the previous code works for me Local $Content = FileRead("IE11_main.log") Local $aString = StringRegExp($Content, "(?i)Setup exit code:\N+", 3) If IsArray($aString) Then $Results = $aString[0] MsgBox("", "Results", $Results)
antmar904 Posted April 26, 2016 Author Posted April 26, 2016 #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> Local $Results = "unknown" Local $IE11Log = "C:\Temp\IE_main.log" ;Test log file location Local $hFileOpen = FileOpen($IE11Log, 0) If @error Then MsgBox (0, "error", "error") Exit EndIf Local $Content = FileRead($hFileOpen) Local $aString = StringRegExp($Content, "(?i)Setup exit code:\N+", 3) If IsArray($aString) Then $Results = $aString[0] MsgBox("", "Results", $Results)
mikell Posted April 26, 2016 Posted April 26, 2016 In your code if I replace Local $IE11Log = "C:\Temp\IE_main.log" by Local $IE11Log = "C:\Temp\IE11_main.log" then it works
antmar904 Posted April 26, 2016 Author Posted April 26, 2016 OMG the log file path was wrong, I was missing the (11) in IE11_main.log. Its been a long day. Thank you very much for your help!!!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now