Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


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

13 Jan 2015   #1
Weboh

Windows 7 Ultimate x64
 
 
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 System SpecsSystem Spec
.
19 Jan 2015   #2
Wandering one

Win7 sp1 Pro 64bit / XP sp2 Pro (games only)
 
 

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 System SpecsSystem Spec
19 Jan 2015   #3
Weboh

Windows 7 Ultimate x64
 
 

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

20 Jan 2015   #4
DavidE

Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64
 
 

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 System SpecsSystem Spec
22 Jan 2015   #5
Weboh

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
23 Jan 2015   #6
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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.


Attached Files
File Type: bat th-358276.bat (2.1 KB, 0 views)
My System SpecsSystem Spec
23 Jan 2015   #7
DavidE

Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64
 
 

Quote   Quote: Originally Posted by Weboh View Post
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 System SpecsSystem Spec
Reply

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




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Changed text file default open and cant change it back
So I was looking into making a batch file, followed some bad advice, and set my notepad files to open with cmd. Now even if I go and set default program, it does not save it and will open with cmd the 2nd time. It seems the option to always use the selected type of program is grayed out. How can I...
Software
Create a new text file in lightning speed!
I use windows 7 home premium 64bit. To generate a new text file in a certain directory, we do : Right click empty area -> New -> text document. This consists of 3 steps : 1) right click any emtpy area 2) move the mouse pointer to "New" 3) left click "text document" But I want to...
Customization
Create reg file to change between connecting with proxy server?
How can I create I .reg file or command line to change between connecting with a proxy server (address: proxy or 10.22.12.12, port: 8080) and directly?
Network & Sharing
How to create new text file in one click ?
Hello all, I need to have an option like "new text file" next to "new folder" option below menu bar. Is it possible to tweak registry and do something like this? I am attaching an image to show what exactly i mean.. http://i962.photobucket.com/albums/ae103/kashyaprakesh/2012-06-25_114718.jpg...
General Discussion
How do I change a file's file type (not only file association)?
I need to change a zip file to an epub file. I have heard this can be done, but when I add the .epub after the file name, I notice the file is still actually zip type file when I right click properties. This is causing a problem when I try to open it in in different ebook reader programs. I...
General Discussion
Windows file contents to text file
i need a list of everything on my hard drive i can access in a text file without manually pounding the folder/sub folder and contents names into notepad is there anyway this can be achieved?
General Discussion


Our Sites

Site Links

About Us

Find 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:09.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App