Re saven:
首先保证批处理能在开机时自动运行,这一般不是批处理本身的责任,将它拖动到“启动”菜单中,或在注册表中的 Run 下设置键值。
其次,需要在批处理设置一个计数器,这个计数器通常是一个批处理代码,如同下面代码中的 %temp%\_Countlog.bat 。
:: CountLog.bat - Counter of logon (Test code)
:: Will Sort - 2006/01/22 - CMD@WinXP
@echo off & setlocal
if not exist %temp%\_Countlog.bat goto Count
call %temp%\_Countlog.bat
:Count
set /a _countlog+=1
if "%_countlog%"=="20" goto CountOff
echo 第 %_countlog% 次登陆系统,忽略处理……
echo set _countlog=%_countlog% >%temp%\_Countlog.bat
goto :eof
:CountOff
echo.
echo 登陆系统满20次,执行相应处理……
echo.
goto :eof