Jump to content

Get contents of file


Recommended Posts

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 by antmar904
Link to comment
Share on other sites

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,
 

Link to comment
Share on other sites

#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)

Capture.JPG.61875de57fe40472703a01111c68

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...