Skip to content

Instantly share code, notes, and snippets.

@reneklacan
Last active September 20, 2026 13:09
Show Gist options
  • Select an option

  • Save reneklacan/7825b82723bf0534cbd2eae014e121ca to your computer and use it in GitHub Desktop.

Select an option

Save reneklacan/7825b82723bf0534cbd2eae014e121ca to your computer and use it in GitHub Desktop.
Script to fix AOE4 desync issues
#!/bin/bash
set -ex
STEAM_DIR=/home/$USER/.steam/steam/steamapps
AOE4_DIR=$STEAM_DIR/compatdata/1466860
AOE4_WIN_DIR=$AOE4_DIR/pfx/drive_c/windows
AOE4_WIN_SYS32_DIR=$AOE4_WIN_DIR/system32
AOE4_WIN_SYS64_DIR=$AOE4_WIN_DIR/syswow64
function check_deps() {
which wget || (echo "wget is required (on Ubuntu you can install it with 'sudo apt-get install wget')" && exit 1)
which cabextract || (echo "cabextract is required (on Ubuntu you can install it with 'sudo apt-get install cabextract')" && exit 1)
}
function cleanup() {
local arch=$1
rm -f vc_redist.$arch.exe
rm -rf 0 a{0..11} u{0..31}
}
function backup() {
local timestamp=$(date +%s)
mv ucrtbase.dll ucrtbase.dll.bak-$timestamp
mv concrt140.dll concrt140.dll.bak-$timestamp
mv msvcp140.dll msvcp140.dll.bak-$timestamp
mv vcamp140.dll vcamp140.dll.bak-$timestamp
mv vccorlib140.dll vccorlib140.dll.bak-$timestamp
mv vcomp140.dll vcomp140.dll.bak-$timestamp
mv vcruntime140.dll vcruntime140.dll.bak-$timestamp
}
function download_and_replace() {
local arch=$1
wget https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.$arch.exe
cabextract vc_redist.$arch.exe
cabextract a10
}
function replace_dlls() {
local dir=$1
local arch=$2
cd $dir
backup
cleanup $arch
download_and_replace $arch
cleanup $arch
}
check_deps
replace_dlls $AOE4_WIN_SYS32_DIR x64
replace_dlls $AOE4_WIN_SYS64_DIR x86
@Yohomie99

Copy link
Copy Markdown

@Yohomie99 I posted a how to thread over on Reddit, trying to break it down into easier steps. It is not perfect, but give it a look and see if it answers any of your questions. https://www.reddit.com/r/SteamDeck/comments/yw1u2m/help_wanted_desperately_aoe_4_multiplayer/izu52o4?utm_medium=android_app&utm_source=share&context=3

Thank you! I'll give it a good read and see how we go when we follow those steps.

@broaken13

Copy link
Copy Markdown

@Yohomie99 Those are commands to enter in a terminal (I believe the steam deck uses one called konsole). You'll need to navigate the terminal to the folder where the script is and run them. So, assuming the script is downloaded to the Downloads folder, you'll open a terminal and type:

  1. cd Downloads or wherever the script is to navigate it's folder (cd means change directory)
  2. chmod +x aoe4-mp-fix.sh This will allow you to execute the script
  3. ./aoe4-mp-fix.sh This executes the script

However, I'm looking at this now with my steam deck, and this looks like it might be quite a bit more of a headache than I initially thought. Looks like it might be necessary to enable developer mode in order to download the dependencies and run the script.

@kaidelorenzo

Copy link
Copy Markdown

You don't technically need dev mode to run this on the steamdeck. You can compile cabextract from source in a flatpak runtime. That's why I did just FYI.

@GolDNenex

GolDNenex commented Feb 23, 2023 •

Copy link
Copy Markdown

Distrobox is great on the steam deck.

In the script edit:

$USER

in this line on the top:

STEAM_DIR=/home/$USER/.steam/steam/steamapps

You should have something like that:

STEAM_DIR=/home/goldnenex/.steam/steam/steamapps

install Distrobox and run the script from it.

@ballerguitarer

ballerguitarer commented Aug 16, 2023 •

Copy link
Copy Markdown

Linux noob here (literally, day #3 of Kubuntu here). I ran the code with the set -ex to set -x tweak, and now AOE doesn't even open. Tried uninstalling and reinstalling, but no change, and now none of my games open. Anyone else run into this issue and solve it?

@BloodyIron

Copy link
Copy Markdown

FYI this script does not account for the following scenarios:

  1. If your games are stored on another drive, as in outside your home folder. I myself have two additional storage drives mounted elsewhere, since well, games are big and need to put them different places.
  2. Once adapted to other locations, this script is also intolerant for spaces in parent folders where a Steam Library could be housed at. Like "/mnt/ssd-1tb/Steam Library" kind of deal.

I'm not sure what the best solution to #1 is, however for #2, double quotes are needed to surround the variables in the early parts declaring paths and sub-paths, and then also for the cd $dir step, should be cd "$dir", and the replace_dlls step needs double quotes around both 32 and 64 bit dirs.

The double quotes may be needed for arch too, but I could be wrong there.

I had to manually adapt the script for my situation and hopefully this helps someone else in the future.

@BloodyIron

Copy link
Copy Markdown

Either way though, thanks for this script! \o/

@lc-nyovchev

Copy link
Copy Markdown

For the people who have steam installed by snap, change:

STEAM_DIR=/home/$USER/.steam/steam/steamapps

to:

STEAM_DIR=/home/$USER/snap/steam/common/.local/share/Steam/steamapps

@Principle

Copy link
Copy Markdown

After this script with GE Proton still had the sync issue, it let me get an hour into the match before that tho. I was able to play through shorter matches no problem.

@CrackerJackMack

Copy link
Copy Markdown

I've modified this to be a generic version of this to work with most other games by passing the APP ID. Also collected some additional examples for users so they don't have to edit the file directly (they still can though)

https://gist.github.com/CrackerJackMack/374f49b4ad98e14c0a7e8bbcac668d63

@SkVN-debug

Copy link
Copy Markdown

`+ STEAM_DIR=/var/home/stupeslip/.local/share/Steam/steamapps/

  • AOE4_DIR=/var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860
  • AOE4_WIN_DIR=/var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860/pfx/drive_c/windows/
  • AOE4_WIN_SYS32_DIR=/var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860/pfx/drive_c/windows/system32/
  • AOE4_WIN_SYS64_DIR=/var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860/pfx/drive_c/windows/syswow64/
  • check_deps
  • which wget
    /usr/bin/wget
  • which cabextract
    /usr/bin/cabextract
  • replace_dlls /var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860/pfx/drive_c/windows/system32/ x64
  • local dir=/var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860/pfx/drive_c/windows/system32/
  • local arch=x64
  • cd /var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860/pfx/drive_c/windows/system32/
  • backup
    ++ date +%s
  • local timestamp=1789909661
  • mv ucrtbase.dll ucrtbase.dll.bak-1789909661
  • mv concrt140.dll concrt140.dll.bak-1789909661
  • mv msvcp140.dll msvcp140.dll.bak-1789909661
  • mv vcamp140.dll vcamp140.dll.bak-1789909661
  • mv vccorlib140.dll vccorlib140.dll.bak-1789909661
  • mv vcomp140.dll vcomp140.dll.bak-1789909661
  • mv vcruntime140.dll vcruntime140.dll.bak-1789909661
  • cleanup x64
  • local arch=x64
  • rm -f vc_redist.x64.exe
  • rm -rf 0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 u0 u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11 u12 u13 u14 u15 u16 u17 u18 u19 u20 u21 u22 u23 u24 u25 u26 u27 u28 u29 u30 u31
  • download_and_replace x64
  • local arch=x64
  • wget https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe
    Saving 'vc_redist.x64.exe'
    HTTP response 200 OK [https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe]
    vc_redist.x64.exe 100% [=====================================================================================================================================================================>] 13.89M 6.77MB/s
    [Files: 1 Bytes: 13.89M [5.70MB/s] Redirects: 0 Todo: 0 Errors: 0 ]
  • cabextract vc_redist.x64.exe
    Extracting cabinet: vc_redist.x64.exe
    extracting 0
    extracting u0
    extracting u1
    extracting u2
    extracting u3
    extracting u4
    extracting u5
    extracting u6
    extracting u7
    extracting u8
    extracting u9
    extracting u10
    extracting u11
    extracting u12
    extracting u13
    extracting u14
    extracting u15
    extracting u16
    extracting u17
    extracting u18
    extracting u19
    extracting u20
    extracting u21
    extracting u22
    extracting u23
    extracting u24
    extracting u25
    extracting u26
    extracting u27
    extracting u28
    extracting u29
    extracting u30
    extracting u31
    extracting a0
    extracting a1
    extracting a2
    extracting a3
    extracting a4
    extracting a5
    extracting a6
    extracting a7
    extracting a8
    extracting a9
    extracting a10
    extracting a11

All done, no errors.

  • cabextract a10
    a10: WARNING; possible 16128 extra bytes at end of file.
    Extracting cabinet: a10
    extracting api_ms_win_core_console_l1_1_0.dll
    extracting api_ms_win_core_datetime_l1_1_0.dll
    extracting api_ms_win_core_debug_l1_1_0.dll
    extracting api_ms_win_core_errorhandling_l1_1_0.dll
    extracting api_ms_win_core_file_l1_1_0.dll
    extracting api_ms_win_core_file_l1_2_0.dll
    extracting api_ms_win_core_file_l2_1_0.dll
    extracting api_ms_win_core_handle_l1_1_0.dll
    extracting api_ms_win_core_heap_l1_1_0.dll
    extracting api_ms_win_core_interlocked_l1_1_0.dll
    extracting api_ms_win_core_libraryloader_l1_1_0.dll
    extracting api_ms_win_core_localization_l1_2_0.dll
    extracting api_ms_win_core_memory_l1_1_0.dll
    extracting api_ms_win_core_namedpipe_l1_1_0.dll
    extracting api_ms_win_core_processenvironment_l1_1_0.dll
    extracting api_ms_win_core_processthreads_l1_1_0.dll
    extracting api_ms_win_core_processthreads_l1_1_1.dll
    extracting api_ms_win_core_profile_l1_1_0.dll
    extracting api_ms_win_core_rtlsupport_l1_1_0.dll
    extracting api_ms_win_core_string_l1_1_0.dll
    extracting api_ms_win_core_synch_l1_1_0.dll
    extracting api_ms_win_core_synch_l1_2_0.dll
    extracting api_ms_win_core_sysinfo_l1_1_0.dll
    extracting api_ms_win_core_timezone_l1_1_0.dll
    extracting api_ms_win_core_util_l1_1_0.dll
    extracting api_ms_win_crt_conio_l1_1_0.dll
    extracting api_ms_win_crt_convert_l1_1_0.dll
    extracting api_ms_win_crt_environment_l1_1_0.dll
    extracting api_ms_win_crt_filesystem_l1_1_0.dll
    extracting api_ms_win_crt_heap_l1_1_0.dll
    extracting api_ms_win_crt_locale_l1_1_0.dll
    extracting api_ms_win_crt_math_l1_1_0.dll
    extracting api_ms_win_crt_multibyte_l1_1_0.dll
    extracting api_ms_win_crt_private_l1_1_0.dll
    extracting api_ms_win_crt_process_l1_1_0.dll
    extracting api_ms_win_crt_runtime_l1_1_0.dll
    extracting api_ms_win_crt_stdio_l1_1_0.dll
    extracting api_ms_win_crt_string_l1_1_0.dll
    extracting api_ms_win_crt_time_l1_1_0.dll
    extracting api_ms_win_crt_utility_l1_1_0.dll
    extracting concrt140.dll
    extracting msvcp140.dll
    extracting ucrtbase.dll
    extracting vcamp140.dll
    extracting vccorlib140.dll
    extracting vcomp140.dll
    extracting vcruntime140.dll

All done, no errors.

  • cleanup x64
  • local arch=x64
  • rm -f vc_redist.x64.exe
  • rm -rf 0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 u0 u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11 u12 u13 u14 u15 u16 u17 u18 u19 u20 u21 u22 u23 u24 u25 u26 u27 u28 u29 u30 u31
  • replace_dlls /var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860/pfx/drive_c/windows/syswow64/ x86
  • local dir=/var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860/pfx/drive_c/windows/syswow64/
  • local arch=x86
  • cd /var/home/stupeslip/.local/share/Steam/steamapps/compatdata/1466860/pfx/drive_c/windows/syswow64/
  • backup
    ++ date +%s
  • local timestamp=1789909664
  • mv ucrtbase.dll ucrtbase.dll.bak-1789909664
  • mv concrt140.dll concrt140.dll.bak-1789909664
  • mv msvcp140.dll msvcp140.dll.bak-1789909664
  • mv vcamp140.dll vcamp140.dll.bak-1789909664
  • mv vccorlib140.dll vccorlib140.dll.bak-1789909664
  • mv vcomp140.dll vcomp140.dll.bak-1789909664
  • mv vcruntime140.dll vcruntime140.dll.bak-1789909664
  • cleanup x86
  • local arch=x86
  • rm -f vc_redist.x86.exe
  • rm -rf 0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 u0 u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11 u12 u13 u14 u15 u16 u17 u18 u19 u20 u21 u22 u23 u24 u25 u26 u27 u28 u29 u30 u31
  • download_and_replace x86
  • local arch=x86
  • wget https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe
    Saving 'vc_redist.x86.exe'
    HTTP response 200 OK [https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe]
    vc_redist.x86.exe 100% [=====================================================================================================================================================================>] 13.12M 7.27MB/s
    [Files: 1 Bytes: 13.12M [6.33MB/s] Redirects: 0 Todo: 0 Errors: 0 ]
  • cabextract vc_redist.x86.exe
    Extracting cabinet: vc_redist.x86.exe
    extracting 0
    extracting u0
    extracting u1
    extracting u2
    extracting u3
    extracting u4
    extracting u5
    extracting u6
    extracting u7
    extracting u8
    extracting u9
    extracting u10
    extracting u11
    extracting u12
    extracting u13
    extracting u14
    extracting u15
    extracting u16
    extracting u17
    extracting u18
    extracting u19
    extracting u20
    extracting u21
    extracting u22
    extracting u23
    extracting u24
    extracting u25
    extracting u26
    extracting u27
    extracting u28
    extracting u29
    extracting u30
    extracting u31
    extracting a0
    extracting a1
    extracting a2
    extracting a3
    extracting a4
    extracting a5
    extracting a6
    extracting a7
    extracting a8
    extracting a9
    extracting a10
    extracting a11

All done, no errors.

  • cabextract a10
    a10: WARNING; possible 16128 extra bytes at end of file.
    Extracting cabinet: a10
    extracting api_ms_win_core_console_l1_1_0.dll
    extracting api_ms_win_core_datetime_l1_1_0.dll
    extracting api_ms_win_core_debug_l1_1_0.dll
    extracting api_ms_win_core_errorhandling_l1_1_0.dll
    extracting api_ms_win_core_file_l1_1_0.dll
    extracting api_ms_win_core_file_l1_2_0.dll
    extracting api_ms_win_core_file_l2_1_0.dll
    extracting api_ms_win_core_handle_l1_1_0.dll
    extracting api_ms_win_core_heap_l1_1_0.dll
    extracting api_ms_win_core_interlocked_l1_1_0.dll
    extracting api_ms_win_core_libraryloader_l1_1_0.dll
    extracting api_ms_win_core_localization_l1_2_0.dll
    extracting api_ms_win_core_memory_l1_1_0.dll
    extracting api_ms_win_core_namedpipe_l1_1_0.dll
    extracting api_ms_win_core_processenvironment_l1_1_0.dll
    extracting api_ms_win_core_processthreads_l1_1_0.dll
    extracting api_ms_win_core_processthreads_l1_1_1.dll
    extracting api_ms_win_core_profile_l1_1_0.dll
    extracting api_ms_win_core_rtlsupport_l1_1_0.dll
    extracting api_ms_win_core_string_l1_1_0.dll
    extracting api_ms_win_core_synch_l1_1_0.dll
    extracting api_ms_win_core_synch_l1_2_0.dll
    extracting api_ms_win_core_sysinfo_l1_1_0.dll
    extracting api_ms_win_core_timezone_l1_1_0.dll
    extracting api_ms_win_core_util_l1_1_0.dll
    extracting api_ms_win_crt_conio_l1_1_0.dll
    extracting api_ms_win_crt_convert_l1_1_0.dll
    extracting api_ms_win_crt_environment_l1_1_0.dll
    extracting api_ms_win_crt_filesystem_l1_1_0.dll
    extracting api_ms_win_crt_heap_l1_1_0.dll
    extracting api_ms_win_crt_locale_l1_1_0.dll
    extracting api_ms_win_crt_math_l1_1_0.dll
    extracting api_ms_win_crt_multibyte_l1_1_0.dll
    extracting api_ms_win_crt_private_l1_1_0.dll
    extracting api_ms_win_crt_process_l1_1_0.dll
    extracting api_ms_win_crt_runtime_l1_1_0.dll
    extracting api_ms_win_crt_stdio_l1_1_0.dll
    extracting api_ms_win_crt_string_l1_1_0.dll
    extracting api_ms_win_crt_time_l1_1_0.dll
    extracting api_ms_win_crt_utility_l1_1_0.dll
    extracting concrt140.dll
    extracting msvcp140.dll
    extracting ucrtbase.dll
    extracting vcamp140.dll
    extracting vccorlib140.dll
    extracting vcomp140.dll
    extracting vcruntime140.dll

All done, no errors.

  • cleanup x86
  • local arch=x86
  • rm -f vc_redist.x86.exe
  • rm -rf 0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 u0 u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11 u12 u13 u14 u15 u16 u17 u18 u19 u20 u21 u22 u23 u24 u25 u26 u27 u28 u29 u30 u31
    ^C
    `

Hi, after doing all the modifications in the .sh file, it runs without errors but hangs at this +rm -rf stage. Then no matter how much I wait it doesn't move.
I'm using this fix in the hopes that it'll let me even join a lobby or a MP game, cuz right now I can't have access to MP in aoe4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment