China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 23:16
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed] Regularly clear all contents of log.txt every 25 minutes View 2,523 Replies 19
Floor 16 Posted 2006-07-22 16:54 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
If the thread starter is using XP or 2003 system, you can try the following code. Just add the password, and it will run in a loop. The code hasn't been tested........

@echo off
echo @echo off>>c:\windows\system32\11.bat
echo copy nul d:\log.txt>>>>c:\windows\system32\11.bat
schtasks /create /sc minute /mo 25 /tn "test" /tr c:\windows\system32\11.bat
Floor 17 Posted 2006-07-22 16:57 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Re zxcv:

  Instead of using "del /q d:\log.txt" to delete the original file, can we directly use "echo.>>d:\log.txt" to overwrite and clear it? It should be "echo.>d:\log.txt" instead, and we can't use two >.

Re IceCrack

  The method of using copy nul is much better than the echo. method. I saw it in the forum before, but I forgot it when writing the code and didn't dare to write it out randomly. Hehe, thank you for bringing it up.
Floor 18 Posted 2006-07-22 17:04 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Hehe, bagpipe's code uses schtasks which is quite a headache for me. It seems that a single line of code can solve the problem.

[ Last edited by namejm on 2006-7-22 at 17:07 ]
Floor 19 Posted 2006-07-22 20:14 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 177
Posts 52
Joined 2006-06-04 12:00
20-year member
UID 56562
Status Offline
Floor 20 Posted 2006-07-22 21:33 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by namejm at 2006-7-22 16:57:
Re zxcv:

  You can directly use "echo.>>d:\log.txt" to overwrite and clear instead of using "del /q d:\log.txt" to delete the original file? It should be "echo.>d:\log.txt" instead, and two >> should not be used.

...

I'm sorry, when testing, I used ">>" to observe the byte growth of log.txt, and I didn't change it back when posting ^_^

[ Last edited by zxcv on 2006-7-22 at 21:35 ]
Forum Jump: