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

Weboh

New member
Member
VIP
Local time
9:24 AM
Messages
112
Location
Central Florida
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 My Computer

At a glance

Windows 7 Ultimate x64i7-4702M
Computer type
Laptop
Computer Manufacturer/Model Number
Lenovo Thinkpad E540
OS
Windows 7 Ultimate x64
CPU
i7-4702M
Antivirus
Norton 360
Browser
Pale Moon
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 My Computer

At a glance

Win7 sp1 Pro 64bit / XP sp2 Pro (games only)Intel Core 2 Duo E8400 @ 3.00GHz8.00 GB Dual-Channel DDR2 @ 400MHz (5-5-5-18)1024MB GeForce GTX 560
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home built
OS
Win7 sp1 Pro 64bit / XP sp2 Pro (games only)
CPU
Intel Core 2 Duo E8400 @ 3.00GHz
Motherboard
Intel Corporation DP35DP (CPU1)
Memory
8.00 GB Dual-Channel DDR2 @ 400MHz (5-5-5-18)
Graphics Card(s)
1024MB GeForce GTX 560
Sound Card
NVIDIA High Definition Audio
Monitor(s) Displays
SyncMaster (2048x1152@60Hz)
Hard Drives
240GB Sandisc Extreme Pro SSD
244GB Seagate ST3250410AS
488GB Seagate ST500DM002-1BD142
931GB Western Digital WDC WD1003FZEX
PSU
Corsair 720
Case
ATX
Keyboard
HID Keyboard Device Logitech
Mouse
HID-compliant mouse Microsoft
Other Info
TSSTcorp CDDVDW SH-S223L

HL-DT-ST BD-RE BH12LS35
That won't work. The resolution can't be changed in the shortcut; it can only be changed through the .ini.
 

My Computer My Computer

At a glance

Windows 7 Ultimate x64i7-4702M
Computer type
Laptop
Computer Manufacturer/Model Number
Lenovo Thinkpad E540
OS
Windows 7 Ultimate x64
CPU
i7-4702M
Antivirus
Norton 360
Browser
Pale Moon
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 My Computer

At a glance

Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x6...AMD Athlon II x4 6206GB GSkill DDR2 800AMD 4670 GPU + AMD 4200 IGP
Computer type
PC/Desktop
Computer Manufacturer/Model Number
home built
OS
Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
CPU
AMD Athlon II x4 620
Motherboard
Gigabyte GA-MA785G-UD3H
Memory
6GB GSkill DDR2 800
Graphics Card(s)
AMD 4670 GPU + AMD 4200 IGP
Sound Card
on board Realtek ALC889A
Monitor(s) Displays
RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor
Screen Resolution
1680 x 1050
Hard Drives
OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ...
PSU
Corsair 500 W
Case
Rosewill mid tower
Cooling
CM 90mm rifle
Keyboard
Gyration wireless, Logitech wireless, Dell USB wired
Mouse
Gyration wireless, Logitech wireless, V7 USB wired
Internet Speed
Spectrum - 100Mbps D / 10Mbps U
Antivirus
Avast, MBAM3, EMET, WinPatrol
Browser
Pale Moon, Firefox, IE
Other Info
2 multi-boot PC's
Mainly HTPC/Office/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.

Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.

Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner.
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 My Computer

At a glance

Windows 7 Ultimate x64i7-4702M
Computer type
Laptop
Computer Manufacturer/Model Number
Lenovo Thinkpad E540
OS
Windows 7 Ultimate x64
CPU
i7-4702M
Antivirus
Norton 360
Browser
Pale Moon
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.
 

Attachments

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
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 [B]ZooTycoon "INI" directory[/B]
cd "C:\Program Files (x86)\Microsoft Games\Zoo Tycoon\"

copy /Y ZooTycoon_1280_1024_ini.txt [B]ZooTycoon.ini[/B]

start "ZooTycoon" "C:\Program Files (x86)\Microsoft Games\Zoo Tycoon\[B]Zoo Tycoon.exe[/B]"

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 My Computer

At a glance

Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x6...AMD Athlon II x4 6206GB GSkill DDR2 800AMD 4670 GPU + AMD 4200 IGP
Computer type
PC/Desktop
Computer Manufacturer/Model Number
home built
OS
Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
CPU
AMD Athlon II x4 620
Motherboard
Gigabyte GA-MA785G-UD3H
Memory
6GB GSkill DDR2 800
Graphics Card(s)
AMD 4670 GPU + AMD 4200 IGP
Sound Card
on board Realtek ALC889A
Monitor(s) Displays
RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor
Screen Resolution
1680 x 1050
Hard Drives
OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ...
PSU
Corsair 500 W
Case
Rosewill mid tower
Cooling
CM 90mm rifle
Keyboard
Gyration wireless, Logitech wireless, Dell USB wired
Mouse
Gyration wireless, Logitech wireless, V7 USB wired
Internet Speed
Spectrum - 100Mbps D / 10Mbps U
Antivirus
Avast, MBAM3, EMET, WinPatrol
Browser
Pale Moon, Firefox, IE
Other Info
2 multi-boot PC's
Mainly HTPC/Office/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.

Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.

Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner.
Back
Top