回复 18# 553670595
还是写在这里吧,给新人学习.
BatTo_RunDos().au3:
_FileReplace() 和 _FileReplace2() 一起用.
#include <File.au3>
Dim $szDrive, $szDir, $szFName, $szExt
$batfile = @ScriptDir & "\删除win7事件查看器中的所有日志.bat"
$arrPath = _PathSplit($batfile, $szDrive, $szDir, $szFName, $szExt)
_FileReplace($batfile, 'wevtutil.exe', "_RunDos('wevtutil.exe")
_FileReplace2($batfile, @CRLF, "')" & @CRLF)
Func _FileReplace($SelectFile, $String1, $String2)
FileCopy($SelectFile, $SelectFile & ".bak")
$File1 = FileOpen($SelectFile, 0)
$File3 = StringReplace(FileRead($File1), $String1, $String2)
FileClose($File1)
$File2 = FileOpen($SelectFile, 2)
FileWrite($File2, $File3)
FileClose($File2)
EndFunc ;==>_FileReplace
Func _FileReplace2($SelectFile, $String1, $String2)
$File1 = FileOpen($SelectFile, 0)
$File3 = StringReplace(FileRead($File1), $String1, $String2)
FileClose($File1)
$File2 = FileOpen($SelectFile, 2)
FileWrite($File2, '#include<Process.au3>' & @CRLF)
FileClose($File2)
$File4 = FileOpen($SelectFile, 1)
FileWrite($File4, $File3 & "')" & @CRLF)
FileClose($File4)
FileMove($SelectFile, $szDrive & $szDir & $szFName & '.au3')
FileDelete($SelectFile)
EndFunc ;==>_FileReplace2
|