标题: 请高手帮写一个批处理文件
[打印本页]
作者: coolkone
时间: 2009-9-11 04:13
标题: 请高手帮写一个批处理文件
小弟刚接触批处理 想写个批处理文件。头都想破了都不会,请高手帮忙。
要求 开机30秒后自动重启 重启三次之后 第四次自动删除自身文件```
小弟在此先谢过大家``
作者: 523066680
时间: 2009-9-11 10:41
放在启动目录下
每次重启自动运行,在自身后面重定向一个:1
批处理读取自身判断 :1的个数。如果满3次 删除自身。
演示版
注意,结尾处别转行,这样接数字计算比较方便~@echo off
call :count
if %a% lss 3 (set /p=+1>>%0<nul &echo,shutdown -r -t 30) else (echo,del %0)
pause
exit
:count
set /a a=0
[
Last edited by 523066680 on 2009-9-11 at 10:45 ]
作者: coolkone
时间: 2009-9-12 01:03
用了楼上兄弟的,电脑不会重启。我贴一个我的,大家帮我看看是哪里错了,我这个重启一次就把自身删掉了
@echo off
if not exist c:\1\1.txt echo. >c:\1\1.txt & goto err1
if not exist c:\1\2.txt echo. >c:\1\2.txt & goto err1
if not exist c:\1\3.txt echo. >c:\1\3.txt & goto err1
goto err2
:err1
shutdown -r -t 10
:err2
rd /s /q "%~dp0"
exit