How to create .bat file to change the text in an .ini file?


  1. Posts : 112
    Windows 7 Ultimate x64
       #1

    How to create .bat file to change the text in an .ini file?


    I have the original Zoo Tycoon. It has no built in widescreen support, but it's possible to get it by changing some information in its .ini file. I don't want to leave it at that though, as I also have a 4:3 monitor, and I switch between the two. I don't want to have to go into the ini file and change the lines each time I want to go back to widescreen. What would I need to type into the bat file (I want two of them, one to activate widescreen support, one to deactivate it)? Following is the text of the ini:

    Code:
    [debug]
    logCutoff=15
    sendLogfile=0
    sendDebugger=1
    deltaLog1=0
    deltaLog0=0
    drawfps=0
    drawfpsx=720
    drawfpsy=20
    
    [mgr]
    aimgr=ZTAIMgr
    worldmgr=ZTWorldMgr
    gamemgr=BFGameMgr
    scenariomgr=ZTScenarioMgr
    scriptmgr=BFScriptMgr
    soundmgr=BFSoundMgr
    terrainmgr=ZTAdvTerrainMgr
    
    [language]
    lang=9
    sublang=1
    
    [lib]
    res=res0.dll
    lang=lang0.dll
    
    [resource]
    path=./dlupdate;./updates;./xpack2/loc;./xpack2;./dupdate;./zupdate1;./xpack1/loc;./xpack1;./zupdate;./loc;.
    
    [user]
    fullscreen=1
    screenwidth=1280
    screenheight=1024
    UpdateRate=15
    DrawRate=60
    lastfile=
    
    [advanced]
    ; 0 eTotalQuality
    ; 1 eQuality
    ; 2 eBalance
    ; 3 eSpeed
    ; 4 ePaused
    drag=0
    click=0
    normal=0
    level=3
    loadHalfAnims=0
    use8BitSound=0
    
    [Map]
    mapX=75
    mapY=75
    
    [UI]
    
    ; set this to 0 instead of 1 if you want to try color cursors
    ; if you get a flickering or disappearing cursor, set back to 1
    useAlternateCursors=0
    
    tooltipDelay=1
    tooltipDuration=3000
    MessageDisplay=1
    mouseScrollThreshold=1
    mouseScrollDelay=1
    mouseScrollX=32
    mouseScrollY=32
    keyScrollX=64
    keyScrollY=64
    minimumMessageInterval=60
    defaultEditCharLimit=22
    noMenuMusic=0
    menuMusic=sounds/mainmenu.wav
    menuMusicAttenuation=-1000
    userAttenuation=0
    helpType=1
    playMovie=1
    ; volume for first movie. value from -10000 to 0
    movievolume1=-1000
    playSecondMovie=1
    ; volume for second movie. value from -10000 to 0
    movievolume2=-1000
    maxShortTooltipWidth=200
    maxLongTooltipWidth=400
    progressLeft=231
    progressTop=420
    progressRight=581
    progressBottom=435
    progressRed=255
    progressGreen=184
    progressBlue=43
    progressShadowXOffset=-3
    progressShadowYOffset=3
    progressShadowRed=32
    progressShadowGreen=32
    progressShadowBlue=32
    completedExhibitAttenuation=100
    MSStartingCash =135000
    MSCashIncrement = 5000
    MSMinCash = 10000
    MSMaxCash = 500000
    startedFirstTutorial=1
    progresscalls=1255
    startedDinoTutorial=1
    startedAquaTutorial=1
    lastWindowX=0
    lastWindowY=0
    
    [scenario]
    tutorial=0
    What I need to change is in the User section. I just gave you everything else in case it needs a complete rewrite to make this work. Here's the relevant part, in case you don't want to track it down:
    Code:
    [user]
    fullscreen=1
    screenwidth=1280
    screenheight=1024
    UpdateRate=15
    DrawRate=60
    lastfile=
    I need to change the screenwidth and height to 1366 and 768. Thanks in advance for your help.
      My Computer


  2. Posts : 259
    Win7 sp1 Pro 64bit / XP sp2 Pro (games only)
       #2

    Have you tried making two shortcuts to the game? One left for the regular screen and the second one to add the custom resolution in the properties/target text Art.
      My Computer


  3. Posts : 112
    Windows 7 Ultimate x64
    Thread Starter
       #3

    That won't work. The resolution can't be changed in the shortcut; it can only be changed through the .ini.
      My Computer


  4. Posts : 6,330
    Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
       #4

    What you can do is create a file with ALL the INI settings for each resolution.

    You would have 2 of these files, such as:
    ZooTycoon_1280_1024_ini.txt
    ZooTycoon_1366_768_ini.txt

    Then each of the bat files would copy it's settings file to the "ZooTycoon.ini" file, and then START ZooTycoon.

    I don't know your folder path to the ini file, and I don't have Zoo Tycoon.
    My "testing/bat example" uses the C:\Temp folder and runs mspaint.
    You need to change these to the specific folder(s) and program for Zoo Tycoon.

    Code:
    :: ZooTycoon_1280_1024.bat
    :: This bat file copies the 1280 x 1024 settings to ZooTycoon.ini and starts Zoo Tycoon
    :: anything after "::" are comments 
    
    :: change directory to the ZooTycoon "INI" directory
    cd c:\Temp 
    
    copy /Y ZooTycoon_1280_1024_ini.txt ZooTycoon.ini
    
    start mspaint
    
    pause
      My Computer


  5. Posts : 112
    Windows 7 Ultimate x64
    Thread Starter
       #5

    The folder path is "C:\Program Files (x86)\Microsoft Games\Zoo Tycoon".
    Would I just put that after "cd"?

    And then instead of mspaint, I'd have to put the whole path to the Zoo Tycoon exe, right?

    And lastly, does "pause" end it? I don't want it running "paused" in the background indefinitely.

    Thanks for the help!
      My Computer


  6. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #6

    Hello,

    Apologies I didn't see this thread earlier; I could have replied faster.

    Anyway, does this batch file solve your issue (see attached), Weboh?

    Preview:
    Code:
    @echo off
    setlocal EnableDelayedExpansion
    REM Description:
    REM Iterate through the lines of %INI_FILE% and
    REM look for the "screenwidth" and "screenheight" keys.
    REM If the value of "screenwidth" is 1280, change it to 1366 and vice versa.
    REM If the value of "screenheight" is 1024, change it to 768 and vice versa.
    ::
    set ini_file="C:\Program Files (x86)\Microsoft Games\Zoo Tycoon\ZooTycoon.ini"
    ::
    set fold_temp=%TEMP%\%~n0
    set file_temp=%TEMP%\%~n0\%~n0_tmp.tmp
    :: don't change these!^
    if exist "%FOLD_TEMP%" ( del /q "%FOLD_TEMP%\*"& rd "%FOLD_TEMP%" )
    if not exist "%INI_FILE%" ( echo The input file does not exist. >&2 & exit /b 1 )
    :main
    setlocal
    md "%FOLD_TEMP%"
    copy NUL "%FILE_TEMP%" >NUL
    for %%X in (%INI_FILE%) do ( set ini_file.name=%%~nX)
    for %%X in (%INI_FILE%) do ( set ini_file.extn=%%~xX)
    for %%X in (%INI_FILE%) do ( set ini_file_path=%%~dpX& set ini_file_path=!INI_FILE_PATH:~0,-1!)
    attrib "%INI_FILE%" -r -s -h
    for /f "tokens=1,* delims=]" %%L in (' find /n /v "" ^<"%INI_FILE%" ') do (
     set break_value=FALSE
     if "%%M"=="" ( echo.>>"%FILE_TEMP%" ) else (
      set line=%%M
      if /i "!LINE:~0,9!"=="screenwid" call :screenw "!LINE!"
      if /i "!LINE:~0,9!"=="screenhei" call :screenh "!LINE!"
     )
     if !BREAK_VALUE!==FALSE ( echo.%%M>>"%FILE_TEMP%" )
    )
    ren "%FILE_TEMP%" "%INI_FILE.name%%INI_FILE.extn%"
    replace "%FOLD_TEMP%\*" "%INI_FILE_PATH%" >NUL
    del /q "%FOLD_TEMP%\*"
    rd "%FOLD_TEMP%"
    endlocal REM End of script.
    exit /b 0
     
    REM Functions below.
    :screenw line
    setlocal
     set break_value=TRUE
     for /f "tokens=1,2 delims==" %%A in ("%~1") do (
      if "%%B"=="1280" echo.%%A=1366>>"%FILE_TEMP%"& goto :break
      if "%%B"=="1366" echo.%%A=1280>>"%FILE_TEMP%"& goto :break
     )
     echo no1
     echo.%~1>>"%FILE_TEMP%"
     :break
    endlocal & set BREAK_VALUE=%BREAK_VALUE%
    goto :eof
    :screenh line
    setlocal
     set break_value=TRUE
     for /f "tokens=1,2 delims==" %%A in ("%~1") do (
      if "%%B"=="1024" echo.%%~A=768>>"%FILE_TEMP%"& goto :break
      if "%%B"=="768" echo.%%~A=1024>>"%FILE_TEMP%"& goto :break
     )
     echo.%~1>>"%FILE_TEMP%"
     :break
    endlocal & set BREAK_VALUE=%BREAK_VALUE%
    goto :eof
    Make sure "ini_file" points to the correct location of your ".ini" file (you didn't tell us the name of this file) before you run it.
    How to create .bat file to change the text in an .ini file? Attached Files
      My Computer


  7. Posts : 6,330
    Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
       #7

    Weboh said:
    The folder path is "C:\Program Files (x86)\Microsoft Games\Zoo Tycoon".
    Would I just put that after "cd"?

    And then instead of mspaint, I'd have to put the whole path to the Zoo Tycoon exe, right?

    And lastly, does "pause" end it? I don't want it running "paused" in the background indefinitely.

    Thanks for the help!
    For the cd command, you need to use the folder path to where the ZooTycoon.ini file is.
    Yes, I tested with mspaint because i don't have Zoo Tycoon.
    The pause statement can be deleted or commented after you have the bat file working.
    It's there so you can see any errors, and post them in a screen print if needed.
    The bat file by Pyprohly looks good and you may prefer that solution.
    Then you wouldn't need the 2 extra "ini" files my approach uses.
    Nice work Pyprohly !

    Here is something closer for you ...

    Code:
    :: ZooTycoon_1280_1024.bat
    :: This bat file copies the 1280 x 1024 settings to ZooTycoon.ini and starts Zoo Tycoon
    :: anything after "::" are comments 
    
    :: change directory to the ZooTycoon "INI" directory
    cd "C:\Program Files (x86)\Microsoft Games\Zoo Tycoon\"
    
    copy /Y ZooTycoon_1280_1024_ini.txt ZooTycoon.ini
    
    start "ZooTycoon" "C:\Program Files (x86)\Microsoft Games\Zoo Tycoon\Zoo Tycoon.exe"
    
    pause :: delete or comment out the pause statement when done testing/debugging
    I guessed at filenames and the ini directory name, so i won't be surprised if you get errors.

    You may need to change the ini directory
    You may need to change the ZooTycoon.ini filename
    You may need to change the Zoo Tycoon.exe filename
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 04:20.
Find Us