Search
  • Samuel Barthelemy

Fixing EA's directx issues with python.

Updated: Feb 19, 2019

So I game some, lets get that out of the way. I recently decided (against my best judgement) to get the Origin's yearly subscription to get access to most games in their library for the included price. Notice I didn't say free, because it's not free if you are paying... Marketing at it's finest.


Lets get to the issue at hand

So every game I would download would fail at installing DirectX library. My first instinct was to see what google says about this. A lot of people with similar issues, but I finally found a good article on how to fix it: nickyfixit.com/2019/02/error-a-redistributable-package-directx-was-not-installed-successfully-setup-cannot-continue-4294967287/


Overall the fix is to remove all CAB files in the directory except those with the 2010 date in the title, and the actual installer.


The issue is you have to do this for every game, at least in my case I do. So I'm lazy (hense why I am a systems engineer), I really don't feel like doing this to every game. Lets make a one click script that can do this for us. I could use powershell, but I hate powershell (this is a different topic, but anyone who knows me, knows I hate powershell with a passion; I can write in it, i just have 0 enjoyment doing so). A python script can do this pretty easily. Start off by defining the solution.


Solution: Delete all CAB files not matching a 2010 title and not being an .exe or .dll extension in the \Origin Games\GAMENAME\__Installer\directx\redist\ directory.


Break it down into manageable steps:


1. Go to the default origin game installation directory.

2. Find all game folders in the directory and see if they have a __Installer\directx\redist folder.

3. Find all files NOT matching our requirements and delete them.

4. Launch installer (preferably in background mode if it has the options.)


DISCLAIMER: I don't normally write my code this verbose, but since I'm doing a blog post I want to make it easy to follow along.


Shouldn't take more than a couple mins (way less time then it takes to write this post), lets get started:


code outline:





SIDENOTE: Ok, so it's been about 1.5 hours as I have been looking for a better way to display code in the blog post... My goodness Wix, fix your editor. It is complete trash, can't even select text and mark it as code. I took time to look through websites that allow you to embed code to show people, but it's mostly for web languages, not python. That was frustrating, but lets continue on. All code will be screenshots for now, sorry guys.


Ok, so the top part will need to be rearranged due to function definitions above. In the python language, your functions need to be in reverse order as they need to be defined before called, there are ways around this but that's a different topic.

I also added in function parameters that i'll be using.





So lets make the first function, yes this is far overkill the way I am writing but I'm hoping it will help people learn:




Now for checking if directx folder is there:


Now we are deleting the files:



Finally, we launch the executable:



Full code should look like this:




So, this script should go through and automate the deleting of cabs that arent needed and then installing the executables.


I tried to comment stuff as much as possible.

Your welcome EA.


Code is here:

https://github.com/bartimus-primed/EADirectXFix



1,085 views
  • Facebook
  • Twitter
  • LinkedIn

©2019 by Bartimus. Proudly created with Wix.com