Sign in to follow this  
Followers 0
can7

Green programmer here

5 posts in this topic

Hi everyone

I need some help and advice with script to read Log files in a folder and to find if a certain string is in the log file if the string exist launch an program.

The log files are named and created by date example name would be Conn_20091119.log

I need to be able to run this script via the network to PCs which has a certain string in these log file. an example of the string I'm searching for is GUID:[d0f4861b-5dbc-44d6-a84d-ac7e64b5f7b9]

If this string is found it will launch the update.exe file.

Thank you for your in advance.

Can7

Share this post


Link to post
Share on other sites



$logfile="Conn_20091119.log"
$key="GUID:[d0f4861b-5dbc-44d6-a84d-ac7e64b5f7b9]"
$programpath="C:\update.exe"

; Open file for reading
$file = FileOpen($logfile, 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read contents of filee into $data variable
 $data = FileRead($file)
 
; Close file
FileClose($file)

; Look for $key in $file and launch program if found
If Not (StringInStr($data,$key)==0) Then
    ShellExecute($programpath)
EndIf

Is this what you were looking for?

Share this post


Link to post
Share on other sites

$logfile="Conn_20091119.log"
$key="GUID:[d0f4861b-5dbc-44d6-a84d-ac7e64b5f7b9]"
$programpath="C:\update.exe"

; Open file for reading
$file = FileOpen($logfile, 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read contents of filee into $data variable
 $data = FileRead($file)
 
; Close file
FileClose($file)

; Look for $key in $file and launch program if found
If Not (StringInStr($data,$key)==0) Then
    ShellExecute($programpath)
EndIf

Is this what you were looking for?

Yes this is want I was looking for! Thank you for your help.

I just found out the GUID:[d0f4861b-5dbc-44d6-a84d-ac7e64b5f7b9]is listed in the registry. I think it is much easier to just look in the registry for that value and launch the update, instead of checking a bunch of log files.

My new question is how do I change your script to check the registry instead for the following key?

"HKEY_LOCAL_MACHINE\SOFTWARE\xxx\xxx\CurrentVersion", "GUID", "REG_SZ", "d0f4861b-5dbc-44d6-a84d-ac7e64b5f7b9"

Can7

Share this post


Link to post
Share on other sites

$readreg = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\xxx\xxx\CurrentVersion","GUID")

If ($readreg=="d0f4861b-5dbc-44d6-a84d-ac7e64b5f7b9") Then
    ShellExecute("C:\update.exe")
EndIf

When doing projects using Autoit the help file is an invaluable tool.

Share this post


Link to post
Share on other sites

$readreg = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\xxx\xxx\CurrentVersion","GUID")

If ($readreg=="d0f4861b-5dbc-44d6-a84d-ac7e64b5f7b9") Then
    ShellExecute("C:\update.exe")
EndIf

When doing projects using Autoit the help file is an invaluable tool.

Thanks again smartee! I been trying use the help files. I'm very new to programming so I'm pretty lost when it comes to putting all the commands to get there.

I'm going to give your script a go and see if it works for me.

many thanks again.

Can 7

Share this post


Link to post
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
Sign in to follow this  
Followers 0