AutoIT Example – FileExist checking and write to file for logging


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;==========================================================================
;
; NAME: write to file example
; AUTHOR: John Sorensen
;
; COMMENT: login autoIT script/snippet to check for file and log if exists
;
;==========================================================================



;check if file exists, if so then  log and exit
If FileExists(@ProgramFilesDir & "\program\someprogram") Then
 
$PCName = @ComputerName
$file = Fileopen("\\server\shared_folder\log.txt", 1)

; Write month/day @ time
FileWrite($file, @mon & "/" & @MDAY  & " @ " & @HOUR & ":" & @MIN & " - ")
; Write computer name along with text
FileWrite($file, $PCName & " - " &  "File Exists")
; go to next line
FileWrite($file, @CRLF)
FileClose($file)

 
  Exit
EndIf




You can leave a response, or trackback from your own site.


Further Reading
    None Found




Leave a Reply

Anti-Spam Quiz:

Twitter Delicious Facebook Digg Stumbleupon Favorites More
334 queries in 3.335 seconds.