I found a solution.
When you get the error, keep it like it is because if you close the dialog the following folder is removed. Then go to "C:\Program Files\Electronic Arts" and copy its contents.
After the copy you can close the error dialog and look for "EADesktop.exe" run this. In my case I got a missing dll exception.
I searched on google for this. The solution was to go into windows settings => apps => installed apps => Microsoft visual c++ 2015-2019 redistributable => click the 3 dots => click change => click repair.
After this I tried installing the EA app again now it continued succesfully.