Archive: Reading the last line of a file on successfull Java Install


Reading the last line of a file on successfull Java Install
Hi

I'm try to write a script that will automatically install Java if needed. So far I'm detecting through the registry what version of java is installed and downloading it if appropriate. My problem comes in that I don't know how to tell whether it has been successfully installed if need be. At the moment I've got it writing a log file for the install. What I want to do is parse the log file to get the last line which looks like this...

"MSI (s) (98:58): Product: Java 2 Runtime Environment, SE v1.4.2_06 -- Installation operation completed successfully."

I then want to use the StrStr function in the manual to look for the string "Installation operation completed successfully"

My read-the-last-line function looks like this...

Function ReadLastLine
ClearErrors
FileOpen $0 "setup.log" "r"
loop:
FileRead $0 $1 100
;Dumpstate::debug
DetailPrint $1
IfErrors done
Goto loop
done:
DetailPrint $1
FileClose $0
Push $1
FunctionEnd

It doesn't matter what I put for the max length, it always only reads in one character from the file.

I'd be grateful for any help.


May be installer's exit code also can help (MSI in your case), ExecWait sets user' variable with this value.


Function LineRead
http://nsis.sourceforge.net/archive/...ances=0,11,311