Jump to content

Silent Logging to a .txt file


Recommended Posts

Hi All,

Before I explain further, please see my codes below as it should give you an understanding of what I'm trying to accomplish.

$Success = "All services have started successfully."
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
If (@HOUR > 12) Then
 $Hour = @HOUR - 12
 Send (@MON & "/" & @MDAY & "/" & @YEAR & "; " & $Hour & ":" & @MIN & " PM"  & ".  " & $Success)
Else
 Send (@MON & "/" & @MDAY & "/" & @YEAR & "; " & @HOUR & ":" & @MIN & " AM"  & ".  " & $Success)
EndIf
Sleep (1000)
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Send("!y")
WinWaitActive("Save As", "Save &in:")
Send ("service_log")
Sleep (500)
Send ("!s")
Sleep (1000)
If WinActive ("Save As", "Do you want to replace") Then
 Send ("!y")
EndIf

Basically, I want all this to be silent instead of windows popping up on the screen doing what it is written in the codes. I want it to be able to keep/save the log file in a directory (anywhere, doesn't matter). The next time that it runs, it writes the log on the next line, save it, and so forth. This way I can refer back to the log file to check whether the installation runs completely or not.

A hint: if the log file exists, check for empty line to write the success comment, and save. Else, create a new log.txt file, writes to first available space, and then save.

I searched the knowledge base, couldn't find much that fits what I wanted it to do nor do I know much about silent logging. Please shed some lights if this is your expertise.

Much appreciated. :D

Link to comment
Share on other sites

If there is no specific reason for using notepad, why not just use FileWrite or FileWriteLine? Good examples of how to use both is in the help file.

[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Link to comment
Share on other sites

It will probably be much easier with FileWrite() or FileWriteLine() than trying to script notepad in the backround.

LOL...pretty much the same thing written at the same time....

[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...