Monday, July 19, 2021

Portable GTA IV on PC

This method works for any older GFWL-based GTA IV  1.0.0.0 - 1.0.8.0. If you have later game version you should downgrade it first.

Portable GTA IV became possible due to XLivelessAddon settings and savegame folders redirection.

  • Copy GTA IV game folder and XLivelessAddon into your portable device
  • Edit plugins\XLivelessAddon.ini so that it contains
    CustomSavePath = "_savegame"
    CustomSettingsPath = "_settings"
  • Create these two folders _savegame and _settings in GTA IV game folder
  • (optional) Copy your GFWL-compatible savegames into _savegame folder
  • Create portableIV.bat (see below) in game folder and run it from there. The script will start the game. Modify graphics settings and key mappings as needed and exit the game.
  • Go into subfolder _settings\Settings and copy SETTINGS.CFG as SETTINGS.CFG.{PC_NAME_HERE}
    Example:
      If your PC name is NEW-PC its portable settings file must be named SETTINGS.CFG.NEW-PC
    Script will remind you to do this if your current PC has no corresponding SETTINGS.CFG.{PC_NAME_HERE}. 
  • (optional) If you need custom commandline.txt file for each PC you may edit portableIV.bat so that it contains in the beginning
      set COPY_COMMANDLINETXT=1
    and then create in game folder files commandline.txt.{PC_NAME_HERE} for each PC

portableIV.bat

@echo off
rem When PC change detected commandline.txt.%COMPUTERNAME% is copied as commandline.txt
set COPY_COMMANDLINETXT=0
rem The settings subfolder name must be the same as in XLivelessAddon.ini
rem    CustomSettingsPath = "_settings"
set CustomSettingsPath=_settings

rem This is actual folder that contains SETTINGS.CFG
rem For each computer custom settings file must be named SETTINGS.CFG.{COMPUTERNAME}
set settingsfolder=%CustomSettingsPath%\Settings
rem If settings files differ more than mindiff bytes consider them different
rem This number should be more than 2 as for identical files fc /b reports 2 lines
rem   Comparing files {file1} and {file2}
rem   FC: no differences encountered
set mindiff=6
setlocal enabledelayedexpansion
set /a p=0 > nul

if not exist %CustomSettingsPath% (
  echo Settings subfolder not found - you must create it manually!
  echo The name must be the same as CustomSettingsPath in XLivelessAddon.ini
  pause
  goto :eof
) else (
  if not exist %settingsfolder% (
     echo First run detected.
     if exist "%LOCALAPPDATA%\Rockstar Games\GTA IV\Settings\SETTINGS.CFG" (
       echo Using default "%LOCALAPPDATA%\Rockstar Games\GTA IV\Settings\SETTINGS.CFG" as a template
       md %settingsfolder%
       copy /y  "%LOCALAPPDATA%\Rockstar Games\GTA IV\Settings\SETTINGS.CFG" %settingsfolder%\SETTINGS.CFG > nul
       pause
     )
     echo Configure your graphics settings in the game and
     echo     copy %settingsfolder%\SETTINGS.CFG as %settingsfolder%\SETTINGS.CFG.%COMPUTERNAME%
     pause
  ) else (
     if not exist %settingsfolder%\SETTINGS.CFG.%COMPUTERNAME% (
       echo Portable settings file for this PC not found!
       echo After you configured graphics settings in the game make sure to copy modified
       echo       %settingsfolder%\SETTINGS.CFG as %settingsfolder%\SETTINGS.CFG.%COMPUTERNAME%
       pause
     ) else (
       if not exist %settingsfolder%\SETTINGS.CFG (
         echo Using settings file SETTINGS.CFG.%COMPUTERNAME%
         echo After making significant graphics settings in the game make sure to copy updated
         echo       %settingsfolder%\SETTINGS.CFG as %settingsfolder%\SETTINGS.CFG.%COMPUTERNAME%
         copy /y %settingsfolder%\SETTINGS.CFG.%COMPUTERNAME%  %settingsfolder%\SETTINGS.CFG > nul
       ) else (
         rem Must compare settings file to find out if current SETTINGS.CFG is from this computer
         for /f %%D in ('fc /b %settingsfolder%\SETTINGS.CFG %settingsfolder%\SETTINGS.CFG.%COMPUTERNAME%') do (
               set /a p=p+1 > nul
         )
         rem echo Found !p! differences
         if !p! LEQ %mindiff% (
           echo Looks like config file is for this PC
         ) else (
           echo Copying settings file for this PC - SETTINGS.CFG.%COMPUTERNAME%
           echo After making significant graphics settings in the game make sure to copy updated
           echo       %settingsfolder%\SETTINGS.CFG as %settingsfolder%\SETTINGS.CFG.%COMPUTERNAME%
           copy /y %settingsfolder%\SETTINGS.CFG.%COMPUTERNAME%  %settingsfolder%\SETTINGS.CFG > nul
           if %COPY_COMMANDLINETXT%==1 (
             if exist commandline.txt.%COMPUTERNAME% (
               echo Copying commandline.txt for this PC - commandline.txt.%COMPUTERNAME%
               copy /y commandline.txt.%COMPUTERNAME% commandline.txt > nul
             )
           )
         )
       )
     )
  )
  echo Starting GTA IV
  start GTAIV.exe
)

11 comments:

  1. You deserve a medal! I mean it! This deserves way more attention. I mod GTA IV a lot and have lots of different patch versions on my hard drive and it was such a pain to back up saves and settings all the time as to not break the game.
    All this pain is now over and I can't tell you how glad I am! It makes everything so much easier. Also your tutorial was very easy to understand and it worked first try!

    T H A N K Y OU

    ReplyDelete
    Replies
    1. You are welcome. I just would like to not that if you have single PC you may skip portableIV.bat as its settings-juggling logic is not needed and you may launch GTAIV.exe directly from corresponding folder.

      Delete
  2. Hello Anton. First thing I got to say, incredible GTA IV content you got man. Second, I want some help with running GTA IV correctly. I want silky smooth gameplay and am using DXVK. I am using patch 1.0.7.0 and my GPU is Radeon RX580 8gb. So how much VRAM should I specify in commandline?

    ReplyDelete
    Replies
    1. Hello, thanks! For older game versions use this table and experiment https://ant-sh.blogspot.com/2020/09/easy-downgrade-gta-iv-to-1040.html#_Toc50220895 In general 2Gb VRAM or above is OK as long as Resource Usage in Graphics menu is green.

      Delete
    2. Thanks. Another question, I get really long loading times with patch 1.0.7.0. It only happens with this patch. Game performance is fine but the loading times are really frustrating. ColAccel manages to reduce it a little bit but not much. Do you have any potential solution to this?

      Delete
    3. I have some workarounds but no definitive solution as it has something to do with particular PC/OS/driver. FusionFix and/or enabling/disabling fps limiter may help.
      https://ant-sh.blogspot.com/2020/09/easy-downgrade-gta-iv-to-1040.html?showComment=1630512160568#c5034333421747188290

      Delete
    4. By fps limiter do you mean the ingame V-sync option? Or another fps limiter. I have fusionfix installed in the game but it doesn't seem to do loading times any good.

      Delete
    5. Try with ingame vsync on and off. I mean some external fps limiter e.g. RTSS. Experiment with some compatibility options for GTAIV.exe and if you find something that helped you please share.

      Delete
    6. Thanks for your help. I will try it out and let you know.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Don't working. Just say Seculauncher Failed to Start Application 2000

    ReplyDelete