#NoEnv
#SingleInstance force
SetWorkingDir %A_ScriptDir%
FileEncoding UTF-8
SetBatchLines, -1
drive := "C:\"
file := "Dummy.txt"
path := drive . file
text := "Dummy"
if FileExist(drive) {
Loop {
EmptyFile(path)
FileAppend, % text, % path
}
}
EmptyFile(file) {
hFile := DllCall("CreateFile", Str, file, UInt, 0x40000000, UInt, 3, UInt, 0, UInt, 5, UInt, 0, UInt, 0)
DllCall("CloseHandle", UInt, hFile)
return hFile > 0 ? 1 : hFile
}
But ofc this empties the file before it gets overwritten...
OpenFile() would impose too many problems (no unicode, no > 128 file path length...)