@echo off setlocal enabledelayedexpansion REM 生成随机的前景色和背景色 REM 生成8到15之间的随机数 set /a "randomForeground=%random% %% 8 + 8" REM 生成0到7之间的随机数 set /a "randomBackground=%random% %% 8" REM 将随机数转换为十六进制 set "foregroundHex=!randomForeground!" set "backgroundHex=!randomBackground!" if !randomForeground! == 10 set foregroundHex=A if !randomForeground! == 11 set foregroundHex=B if !randomForeground! == 12 set foregroundHex=C if !randomForeground! == 13 set foregroundHex=D if !randomForeground! == 14 set foregroundHex=E if !randomForeground! == 15 set foregroundHex=F REM 设置颜色 ::echo !backgroundHex!!foregroundHex! color !backgroundHex!!foregroundHex! set "currentDir=%~dp0" if "%currentDir:~-1%"=="\" set "currentDir=!currentDir:~0,-1!" for %%i in ("%currentDir%") do set "parentDir=%%~ni" title %parentDir% ::title %~dp0 set count=0 :loop set /a "count=!count! + 1" run.exe echo ===============run.exe 第 !count! 次运行结束。 if !count! GEQ 99 goto :EOF timeout 30 goto :loop endlocal