genSerial

genSerial.bat文件
@echo off
set %0~SNFile=%SNFile%
set %0~SN=%SN%
set %0~result=
set SNFile=SN.txt
if "%1" =="reset" (
set /a SN=0
goto save
)
if exist %SNFile% (
for /f %%i in (%SNFile%) do set /a SN=%%i
set /a SN+=1
) else (
set /a SN=0
)
:save
echo %SN% >%SNFile%
set %0~result=%SN%
set SNFile=!%0~SNFile!
set SN=!%0~SN!
使用实例1
@echo off
Setlocal enabledelayedexpansion
set path=%path%;%cd%\lib
call genSerial
set serial=%genSerial~result%
echo the serial is %serial%
call genSerial
set serial=!genSerial~result!
echo the serial is %serial%
call genSerial reset
set serial=!genSerial~result!
echo after reset,the serial is %serial%
pause

你可能感兴趣的:(Path)