1. Assume that the%appdata%\leez program directory has the cache subdirectory and configuration file Config.ini
The contents are:
[Version]
Version=1.0.0.123
[Options]
windowwidth=1920
windowheight=1080
[Login]
Currentaccount=leez
2. Modify the WindowWidth and WindowHeight values through the bat script and delete the cache subdirectory in the Leez program directory, and the other configuration items remain unchanged
3.bat Script Implementation
@echo off
Title Config configuration modification
: Start
Echo =======================================================
Echo Select 1,1920*1080
Echo Select 2,1600*900
Echo Select 0, exit
Echo =======================================================
Set Programdir=%appdata%\leez Program
Set Configfile=config.ini
Set Cachedir=cache
CD "%programdir%"
set/p choice= Please select:
:: Environment Switch Selection
If "%choice%" Equ "" Goto start
If "%choice:~0,1%" equ "1" (
:: Select 1,1920*1080
Set rep_windowwidth=1920
Set rep_windowheight=1080
Goto change)
If "%choice:~0,1%" Equ "2" (
:: Select 2,1600*900
Set rep_windowwidth=1600
Set rep_windowheight=900
Goto change)
If "%choice:~0,1%" equ "0" (
Goto end)
Goto Start
: Change
Setlocal enabledelayedexpansion
for/f "tokens=1-2* delims=="%%a in (%configfile%) do (
Set "Var=%%b"
If not!var!. ==. (
If%%a==windowwidth (Echo%%A^=%REP_WINDOWWIDTH%>>%CONFIGFILE%.BK
) Else if%%a==windowheight (Echo%%A^=%REP_WINDOWHEIGHT%>>%CONFIGFILE%.BK
) Else Echo%%A^=%%B>>%CONFIGFILE%.BK
) Else Echo%%A>>%CONFIGFILE%.BK
)
:: Delete Cached data
If exist "%cachedir%" (
rmdir/s/q "%cachedir%"
)
:: Replace old configuration file
Move "%CONFIGFILE%.BK" "%configfile%"
echo "Configuration modification Complete"
Goto Start
: End
Exit
Configuration file modification in%appdata% directory (BAT scripting mode)