特点:不生成临时文件,不增加文件大小;缺点:比较危险,在运行时可能会报错(不影响运行),代码复杂。
:: 0
@echo off
set /p n=<%~nx0
call, set n=%n:~2%
set /a n+=1
setlocal enabledelayedexpansion
for /f "delims=" %%i in ('type %~nx0') do (
set /a m+=1
if !m! equ 1 (
echo :: !n!>%~nx0
) else (
endlocal&echo %%i>>%~nx0
)
)
ren %~nx0 已运行%N%次.bat
Last edited by zw19750516 on 2008-4-21 at 10:53 AM ]