0

I'm creating a standalone installation pack for an existing map editor, for my fellow game map makers. The map editor is called Finalsun, and it has an INI file called FinalSun.ini, inside the .ini file, it should refer to the game.exe like this:

**[TS]

Exe=PathToExeFile**

But there is nothing at the 'exe=' key. And most people don't know how to fix it. So it needs the path of the Game.exe that resides up one level, So I want to create a batch file that adds the user's absolute path of the game.exe at the 'Exe=' key

finalsun.ini is inside Folder1/Map editor/finalsun.ini the game.exe is inside Folder1/Game.exe (up one level of finalsun.ini)

So to clarify, I need a command for my batch file that will edit FinalSun.ini to have:

[TS]

Exe=Usersdirectories/Folder1/game.exe

The batch file i'm using for the installation is also in the Folder1.

UPDATE:

Ok i did some research and came across something that creates a new copy of the ini file and makes the desired changes on https://stackoverflow.com/questions/25635303/how-to-edit-multiple-text-lines-in-a-ini-file-using-batch-script

So The copied file is fine, i can still make that that work, the only thing i have to figure out now is how to add the absolute path of the game.exe (one folder up from current)

This is the code i'm using:

@ECHO OFF
SETLOCAL
SET "tssection="
(
 FOR /f "tokens=1*delims=" %%a IN (Convertfile.ini) DO (
  FOR /f "tokens=1*delims== " %%b IN ("%%a") DO (
   SET repro=Y
   IF "%%c"=="" (
    SET "tssection="
    IF /i "%%b"=="[TS]" SET tssection=y
   ) ELSE (
    IF DEFINED tssection IF "%%b"=="Exe" (SET "repro="&ECHO(Exe=%INeedPathRightHere%)
   )
   IF DEFINED repro ECHO(%%a
  )
 )
)>Finalsun.ini

FC Convertfile.ini FinalSun.ini

GOTO :EOF

So i need the absolute path of Game.exe (one level up of current directory), where i put %INeedPathRightHere%

2ND UPDATE:

Alright I found a line i'm very happy with, this code works for me:

@echo off
set "file=Map Editor\Finalsun.ini"
SET mypath=%~dp0
if exist "%file%" (
   findstr /v /i "Exe=" "%file%" >"%file%.tmp"
   >>"%file%.tmp" echo/-Exe=%mypath:~0,-1%\Game.exe
   move /y "%file%.tmp" "%file%" >nul
 )
7
  • Why are you asking the same question again? Please don't do that, read and take note of What does it mean if a question is "closed" or "on hold"?. If you have new information you should edit it into the original question instead of asking a new one.
    – DavidPostill
    Apr 4, 2020 at 16:13
  • Oh but i deleted the first one. And i edited my question. Do i have to be even more clear with this question? Its as clear as i can make it :(
    – HollandTS
    Apr 4, 2020 at 16:20
  • Why don't you just edit the ini file?
    – DavidPostill
    Apr 4, 2020 at 16:27
  • Thank you for that question, its because its for other users. I hope I made it clear enough now for reopening.
    – HollandTS
    Apr 4, 2020 at 17:37
  • (1) Do you have any idea how to start?  For example, would you be able to write a batch file that would delete the .ini file?  Rename it?  Create a brand new .ini file, with totally predetermined (known in advance) contents?  Add a line to an existing file?  Change a line in an existing file?  Show us what you already know.  (2) How would your batch file be invoked? Apr 4, 2020 at 23:31

0

You must log in to answer this question.

Browse other questions tagged .