Configuration file modification in%appdata% directory (BAT scripting mode)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.