goodmanjl531

Install Log

24 posts in this topic

Ive been using auto for years so a great tool.   I have recently run into issue with my scripts when i try to append to an install log my script is as follows and it will give me an "Unable to open the script file" error  if i take out the section(first 6 lines) with my log file update it goes away.  I haven't seen this issue before. INSTALL.LOG is an existing file on the machine.  any ideas?  Thanks so much!

 

#include <Date.au3>

$file = FileOpen("C:\crs\RetailStore\INSTALL.LOG", 1)
$tCur = _Date_Time_GetLocalTime()
FileWriteLine($file, "***Installation Started  " & _Date_Time_SystemTimeToDateTimeStr($tCur) & "  ***" & @CRLF)
FileWriteLine($file, "Title: SQL Fix for SERVERNAME*** " & @CRLF)
FileClose($file)





FileInstall("C:\Autoit\IMUPDATE\db_Fix.sql", "C:\corp\Polldown\", 1)
FileInstall("C:\Autoit\IMUPDATE\db_Fix_POLLDOIT.CMD", "C:\corp\Polldown\", 1)
FileChangeDir("C:\corp\Polldown\")


RunWait(@ComSpec & " /c " & 'db_Fix_POLLDOIT.CMD', "");

FileDelete("C:\corp\polldown\db_Fix_POLLDOIT.CMD")
FileDelete("C:\corp\polldown\db_Fix.sql")
Exit

 

Share this post


Link to post
Share on other sites



#include <File.au3>
_FileWriteLog ( $sLogPath, $sLogMsg [, $iFlag = -1] )

This will automaticly create a file named FILENAME.log with Date and Time and the message.


  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Share this post


Link to post
Share on other sites

@RaiNote, no it won't. That will cause a syntax error instead.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@guinness

._. it works fine at my codes.

Edited by RaiNote

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Share this post


Link to post
Share on other sites

Strange, as I just copied your code directly into SciTE and it gave me a syntax error about [] being incorrect. I admit I am not very good at AutoIt programmer, so maybe my setup is wrong.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Hehe @Guinness just copying it won't work that's right but if you Change the params it would work.

Ex:

#include <File.au3>
_FileWriteLog(@ScriptDir & "\myLog.log","LOG MESSAGE1"); @CRLF automaticly!!!!!!!!
_FileWriteLog(@ScriptDir & "\myLog.log","LOG MESSAGE2")
_FileWriteLog(@ScriptDir & "\myLog.log","LOG MESSAGE3")
_FileWriteLog(@ScriptDir & "\myLog.log","LOG MESSAGE4")

 


  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Share this post


Link to post
Share on other sites

Oh silly me! I told you my AutoIt understanding wasn't so great.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Hehe @Guinness just copying it won't work that's right but if you Change the params it would work.

Ex:

#include <File.au3>
_FileWriteLog(@ScriptDir & "\myLog.log","LOG MESSAGE1"); @CRLF automaticly!!!!!!!!
_FileWriteLog(@ScriptDir & "\myLog.log","LOG MESSAGE2")
_FileWriteLog(@ScriptDir & "\myLog.log","LOG MESSAGE3")
_FileWriteLog(@ScriptDir & "\myLog.log","LOG MESSAGE4")

 

WHOOOOOSH!

Share this post


Link to post
Share on other sites

Its too early in the morning for this lol.

But yes _FileWriteLog() is amazing.

I have used it as an install log, and I even used it for a ping script to verify connectivity issues that people were complaining about. 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Can i use the _FileWriteLog()  to append an existing log?  I dont want to create a new log this has to append an existing file. 

Edited by goodmanjl531
update.

Share this post


Link to post
Share on other sites

Dog ate your help file? Your will find the answer there :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Sorry posted before i opened the help file...   It work once then it stopped working.   Below is my code.  is there a limit of how large the logfile can be?   Weird thing is I can run some of my older autoit script fine with my original filewriteline code and it works   It as if my machine wont let it ever run a second time...but only scripts i just worked on this week  older scripts arnt affected.  I did download the newest autoit V3.3.14.1

 

#include <Date.au3>
#include <File.au3>

$file = "C:\crs\RetailStore\INSTALL.LOG"
$tCur = _Date_Time_GetLocalTime()


;FileWriteLine($file, "***Installation Started  " & _Date_Time_SystemTimeToDateTimeStr($tCur) & "  ***" & @CRLF)
;FileWriteLine($file, "Title: SQL Fix for SERVERNAME*** " & @CRLF)
;FileClose($file)

FileInstall("C:\Autoit\IMUPDATE\db_Fix.sql", "C:\corp\Polldown\", 1)
FileInstall("C:\Autoit\IMUPDATE\db_Fix_POLLDOIT.CMD", "C:\corp\Polldown\", 1)
FileChangeDir("C:\corp\Polldown\")


RunWait(@ComSpec & " /c " & 'db_Fix_POLLDOIT.CMD', "");

FileDelete("C:\corp\polldown\db_Fix_POLLDOIT.CMD")
FileDelete("C:\corp\polldown\db_Fix.sql")

_FileWriteLog($file, "***Installation Started  " & _Date_Time_SystemTimeToDateTimeStr($tCur) & "  ***" & @CRLF)
_FileWriteLog($file, "Title: SQL Fix for SERVERNAME*** " & @CRLF)

 

Edited by goodmanjl531
typo

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

ignore this post forum put it in twice

Edited by goodmanjl531
duplicate

Share this post


Link to post
Share on other sites

is there a limit of how large the logfile can be?

How large is it now?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

is there a limit of how large the logfile can be?

How large is it now?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

My current log file is 620K     The weird part is some of my older Scripts work fine no issues  its scripts that i just recently created.  I even tried rebooted my test machine thinking the file might still be open in memory. but luck...

Share this post


Link to post
Share on other sites

620K shouldn't be a problem.
What your script misses is some kind of error checking (makes debugging much easier).
All AutoIt functions give you a return value to check or set @error and/or @extended.
Do something like this:

_FileWriteLog($file, "***Installation Started  " & _Date_Time_SystemTimeToDateTimeStr($tCur) & "  ***" & @CRLF)
If @error Then MsgBox(0, "Error", "_FileWriteLog returned @error = " & @error)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

My script wont even start its errors right away with Unable to open the script file

 

If i comment out the install log part it runs fine. below works no issues  It makes no sense ....

;#include <Date.au3>
;#include <File.au3>

;$file = "C:\crs\RetailStore\INSTALL1.LOG"
;$tCur = _Date_Time_GetLocalTime()

;_FileWriteLog($file, " ***Installation Started  ***" & @CRLF)
;If @error Then MsgBox(0, "Error", "_FileWriteLog returned @error = " & @error)
;_FileWriteLog($file, " Title: SQL Fix for SERVERNAME*** " & @CRLF)
;If @error Then MsgBox(0, "Error", "_FileWriteLog returned @error = " & @error)


FileInstall("C:\Autoit\IMUPDATE\db_Fix.sql", "C:\corp\Polldown\", 1)
FileInstall("C:\Autoit\IMUPDATE\db_Fix_POLLDOIT.CMD", "C:\corp\Polldown\", 1)
FileChangeDir("C:\corp\Polldown\")


RunWait(@ComSpec & " /c " & 'db_Fix_POLLDOIT.CMD', "");

FileDelete("C:\corp\polldown\db_Fix_POLLDOIT.CMD")
FileDelete("C:\corp\polldown\db_Fix.sql")



Exit

 

Share this post


Link to post
Share on other sites

OK did some more debugging and found out its the #Include lines it doesn't like.... Any Ideas??

Share this post


Link to post
Share on other sites

Can you please post the content of the SciTE output pane after having enabled the #include lines?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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