can7 Posted December 3, 2009 Posted December 3, 2009 Hi everyoneI 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.logI 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
smartee Posted December 3, 2009 Posted December 3, 2009 $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?
can7 Posted December 3, 2009 Author Posted December 3, 2009 $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
smartee Posted December 3, 2009 Posted December 3, 2009 $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.
can7 Posted December 3, 2009 Author Posted December 3, 2009 $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
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