在script目录下建立一个文件夹并在此文件夹下生成log文件~怎么写?
Local $FolderName = "Test" ; 存放日志的文件夹名称
Local $FileName = "Log.log" ; 记录日志的文件名称
Local $ParentPath = @ScriptDir &"\"& $FolderName ; 日志的父目录路径
Local $LogPath = $ParentPath &"\"& $FileName ; 日志的路径
Local $LogWords = "日志内容...." ; 写入的日志内容
If Not(FileExists($ParentPath)) Then
DirCreate($ParentPath)
EndIf
Local $file = FileOpen($LogPath,9)
If $file = -1 Then
MsgBox(0, "错误", "不能打开文件.")
Exit
EndIf
FileWriteLine($file,$LogWords)
FileClose($file)
;或者参照
#include <file.au3>
_FileWriteLog("C:\Program Files\autoit3\LOG" & "\" & @computername & ".log","軟件已更新完畢")
_FileWriteLog("C:\Program Files\autoit3\LOG" & "\" & @computername & ".log","電腦名稱為:"&@computername)
_FileWriteLog("C:\Program Files\autoit3\LOG" & "\" & @computername & ".log","IP地址為:"&@IPAddress1)
© 版权声明
THE END
暂无评论内容