herr5407 Posted April 6, 2009 Share Posted April 6, 2009 (edited) Hi all, I've been writing a small sync log that I use to sync to my NAS server to benchmark what kind of time it takes to transfer the backups. Now the creating of the file works but the appending doesn't work. and I have absolutely no idea how to get it to work. Any ideas on appending section? EDIT: Ignore this. I have fixed it.... CODE #include <Word.au3> run("Test.exe") sleep(5000) if ProcessExists("Test.exe") Then $logfile = _WordCreate ("C:\Documents and Settings\Administrator\Desktop\ServerSyncLog.doc",0,0) $append = _WordDocGetCollection ($logfile, 0) $append.Range.insertAfter ("Date Started: " & @HOUR & ":" & @MIN & ":" & @SEC & " / " & @MON & "/" & @MDAY & "/" & @YEAR & @CRLF) _WordQuit ($logfile, -1) EndIf while processexists("Test.exe") sleep(2000) ;Check / How many minutes? 2 sec for test WEnd _WordDocOpen ($logfile,"C:\Documents and Settings\Administrator\Desktop\ServerSyncLog.doc","\ServerSyncLog.doc") $append.Range.insertAfter ("Date Ended: " & @HOUR & ":" & @MIN & ":" & @SEC & " / " & @MON & "/" & @MDAY & "/" & @YEAR & @CRLF) _WordQuit ($logfile, -1) Edited April 6, 2009 by herr5407 Link to comment Share on other sites More sharing options...
DaRam Posted April 6, 2009 Share Posted April 6, 2009 Does the log output have to be a Word Document (first encounter for me ) ?If not switch to a pure AutoIt code (w/o using word.au3) and check the help file for FileWriteLine (and related file function).The other good alternative is _FileWriteLog UDF (file.au3). Link to comment Share on other sites More sharing options...
Valuater Posted April 6, 2009 Share Posted April 6, 2009 Maybe... #include <File.au3> $Path = @ScriptDir & "\Tester.log" $Program = "Notepad.exe" Run($Program) WinWaitActive("") If ProcessExists($Program) Then _FileWriteLog($Path, "Started") While ProcessExists($Program) Sleep(2000) ;Check / How many minutes? 2 sec for test WEnd _FileWriteLog($Path, "Ended" & @CRLF) 8) Link to comment Share on other sites More sharing options...
DaRam Posted April 6, 2009 Share Posted April 6, 2009 Valuater, we are too slow for the OP EDIT: Ignore this. I have fixed it.... Link to comment Share on other sites More sharing options...
herr5407 Posted April 6, 2009 Author Share Posted April 6, 2009 (edited) Well, theoretically it doesn't have to be a Word document. I just had a log file writer script written beforehand so I figured I would use the code I already have.My syntax was completely wrong in the code block that I originally posted. I've gotten it to work properly.Basically I'm using a program to sync data to a NAS server. I'm too lazy to setup Rsync right now. I was to make sure my backup jobs finish before it starts to replicate so this script will come in handy (that isn't shown in the code though).AutoIT (once again), saves the day.The other good alternative is _FileWriteLog UDF (file.au3).I'll check this out as well. Thx! Edited April 6, 2009 by herr5407 Link to comment Share on other sites More sharing options...
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