Jump to content
LaunchBox Community Forums

AutoHotKey Script: Trying to close EA app upon game exit in Launchbox


Recommended Posts

Posted

Hi, I play my share of Mass Effect in LB. I'm sick of after everytime I leave the game, the EA app is staring me in the face.

Then I have to close it in the system tray or task manager.

 

It be more convenient to have a process that closes it for me without any additional buttons.

I tried autohotkey script but I am a beginner and the app is a little over my head. Nevertheless,

I did try google's suggestion here:

 

Run, "C:\Program Files\Electronic Arts\EA Desktop\EADesktop.exe"
Process, Wait, EADesktop.exe 
Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"
Process, WaitClose, MassEffect.exe
Process, Close, EADesktop.exe
ExitApp

I made that into a .ahk file via notepad, It came back with an error. Even removed my game from LB

favorites section (intentional or glitch perhaps?). I placed that ahk file in the "Launching" section of

the game within LB.

What's wrong with that line of code?  Also, I noticed there was an autohk dashboard. Tried different

settings nothing worked. I'm boxing with shadows here. Be glad to try a batch file instead however

I would need a command that closes the EA App on game exit without pressing any additional buttons.

Additionally, I'd like to learn this so I can close steam, blizzard and other apps upon game exit as well.

Posted (edited)

What I meant was I wrote this line of text/parameters:

Quote

Run, "C:\Program Files\Electronic Arts\EA Desktop\EADesktop.exe"
Process, Wait, EADesktop.exe 
Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"
Process, WaitClose, MassEffect.exe
Process, Close, EADesktop.exe
ExitApp

and placed it into an .ahk file using notepad.

Quote

Which line of code? What was the actual error (what did the error say)?

The one specified in my quote

I posted the error, hopefully you can gather something useful from it?

I wouldn't be surprised if it's something simple that slipped underneath my radar.

Error EA App_07-17-2025_02.jpg

Edited by Bucky
Posted
24 minutes ago, Bucky said:

The one specified in my quote

I posted the error, hopefully you can gather something useful from it?

I didn't see any actual error in your original post. And the code itself appeared fine.  But as they say, a picture is worth a thousand words.

In fact, the picture is stating exactly what its error is.

Specifically: The system cannot find the file specified.

The error message is "pointing" to line 001 (aka, the 1st line in your code).

Run, "C:\Program Files\Electronic Arts\EA Desktop\EADesktop.exe"

Open Window Explorer and make sure the file actually exists there. 

Could it be that it's in C:\Program Files\Electronic Arts\EA Desktop\EA Desktop\EADesktop.exe?  I don't have it installed on my system, but a quick search is showing the double folder(s).

  • Game On 1
Posted
13 minutes ago, JoeViking245 said:

I didn't see any actual error in your original post. And the code itself appeared fine.  But as they say, a picture is worth a thousand words.

In fact, the picture is stating exactly what its error is.

Specifically: The system cannot find the file specified.

The error message is "pointing" to line 001 (aka, the 1st line in your code).

Run, "C:\Program Files\Electronic Arts\EA Desktop\EADesktop.exe"

Open Window Explorer and make sure the file actually exists there. 

Could it be that it's in C:\Program Files\Electronic Arts\EA Desktop\EA Desktop\EADesktop.exe?  I don't have it installed on my system, but a quick search is showing the double folder(s).

Problem number 1: Fixed the error at least, thanks to you. Game boots-up!

Problem number 2: The EA App remains even after I've come out of the game. The stubborn bastard refuses to go away. Are we certain the commands laid out here work for what I'm trying to do?

The only other thing I can think of is I put the code into the edit --> launching area of the game, would it need to also be put in emulators --> EA App?

Posted
5 minutes ago, Bucky said:

Problem number 2: The EA App remains even after I've come out of the game. The stubborn bastard refuses to go away. Are we certain the commands laid out here work for what I'm trying to do?

The "intent" of the commands laid out work for what you're trying to do.

Process, WaitClose, MassEffect.exe is simply waiting for that exe file to no longer be running.

Once it's no longer running, Process, Close, EADesktop.exe is the most forceful, brutally unforgiving way to "kill" an app.

There're several things possible as to what's going on.  But kind of a PITA to navigate through. 

 

Any objections to "taking the easy way out"?

In LaunchBox, go to Tools < Manage < Storefronts... and login to you EA Account.  Then have LB auto import the game(s).  As it turns out, I do have EA on my cab.  One of the games is Marvels Guardians of the Galaxy.  When editing the game, there's no associated emulator and the Application Path to the game is some long arse string like:  com.epicgames.launcher://apps/63a555088eb1234298f1e56789b225d8?action=launch&silent=true

I didn't put that there. So must have been LaunchBox doing it thing, "making things mindlessly easy for us". :) 

  • Game On 1
Posted (edited)
23 minutes ago, JoeViking245 said:

There're several things possible as to what's going on.  But kind of a PITA to navigate through. 

 

Any objections to "taking the easy way out"?

In LaunchBox, go to Tools < Manage < Storefronts... and login to you EA Account.  Then have LB auto import the game(s).  As it turns out, I do have EA on my cab.  One of the games is Marvels Guardians of the Galaxy.  When editing the game, there's no associated emulator and the Application Path to the game is some long arse string like:  com.epicgames.launcher://apps/63a555088eb1234298f1e56789b225d8?action=launch&silent=true

I didn't put that there. So must have been LaunchBox doing it thing, "making things mindlessly easy for us". :) 

I see, so what you're saying is the script did it's job! Beyond that there maybe other forces at play. My game is modded and set never to update so the app will ask me to "repair game" which would break the mod. I wonder if the repair dialogue box is the culprit, just to weed out variables, I'll find the option to close out all notification prompts in the app itself. Then again, it could be a million other things blocking the ahk app from closing the EA App and a pita to figure out.

As for taking the easy way... I'm down for whatever that is?

If you meant signing into the EA App from storefronts in LB and installing ME1 I did that already. I changed the path for the executable however to ahk, if there's a better way I'll point back to the game exe again or shortcut.

Edited by Bucky
Posted

my bet is EADesktop.exe has a buttload of child processes and it isn't closing the main parent one. you should not be using Process, Close unless the standard WinClose command isn't getting the job done. going off JoeViking245's point that Process, Close is a forceful method. it's the same as pressing ALT+F4 or pulling the plug right out of the socket lol

using WinClose will close the window, closing all relevant matching processes. Process, Close is only going to close the FIRST process it finds that matches whatever criteria it is looking for.

  • Game On 1
Posted
34 minutes ago, skizzosjt said:

my bet is EADesktop.exe has a buttload of child processes and it isn't closing the main parent one. you should not be using Process, Close unless the standard WinClose command isn't getting the job done. going off JoeViking245's point that Process, Close is a forceful method. it's the same as pressing ALT+F4 or pulling the plug right out of the socket lol

using WinClose will close the window, closing all relevant matching processes. Process, Close is only going to close the FIRST process it finds that matches whatever criteria it is looking for.

So, I tried a bunch of different commands based off what you said.

Unfortunately, none of these worked. I'm stumped.

Tell me where I went wrong in the example below?

Run, "C:\Program Files\Electronic Arts\EA Desktop\EA Desktop\EADesktop.exe"
WinClose, Wait, EADesktop.exe 
Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"
$Esc::WinClose, ahk_exe EADesktop.exe
ExitApp

Posted (edited)
Run, "C:\Program Files\Electronic Arts\EA Desktop\EA Desktop\EADesktop.exe"
WinWait, ahk_exe EADesktop.exe 
Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"
WinWait, ahk_exe MassEffect.exe
WinWaitClose, ahk_exe EADesktop.exe
ExitApp

this is how I would do it. give this a shot and let us know how it goes!

 

 

tip on why those didn't work for ya. I would assume the script is closing the game within nanoseconds after opening it

Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"
WinClose, MassEffect.exe

that runs the game, and the very next line is closing it. (edit: actually it would not close it cause I just noticed it's missing the ahk_exe part)

when you use WinClose to refer to a process you need to use proper AHK criteria syntax. since it's a process it's "ahk_exe". you'll notice my suggestion uses these

 

if you really want to learn some stuff thumb around in the AHK docs page. it helped me a lot. you can find stuff through their content or index tree or search keywords.

https://www.autohotkey.com/docs/v1/

https://www.autohotkey.com/docs/v1/lib/WinClose.htm

https://www.autohotkey.com/docs/v1/misc/WinTitle.htm

 

Edited by skizzosjt
Posted

*sighs* it failed. The app still wouldn't close. Thanks for the documentation, I'll look over it. The closings of EAs app in relation to LB have elluded me again and again.

 

Good news is, if this gets figured out here. It will help the 2-3 people who are trying to do exactly what I'm trying to do. XD

Posted
1 hour ago, Bucky said:

*sighs* it failed. The app still wouldn't close. Thanks for the documentation, I'll look over it. The closings of EAs app in relation to LB have elluded me again and again.

 

Good news is, if this gets figured out here. It will help the 2-3 people who are trying to do exactly what I'm trying to do. XD

sorry that one is on me. clearly did NOT double check my work 🤦‍♂️ I left a line out and flip flopped the intended command. I did the following:

Run the storefront launcher, wait for launcher to exist, run the game, wait for game to exist, wait for the launcher to close....lol makes no sense

 

here is what I intended to do:

Run the storefront launcher, wait for launcher to exist, run the game, wait for game to exist, wait for game to not exist, close the launcher.

Run, "C:\Program Files\Electronic Arts\EA Desktop\EA Desktop\EADesktop.exe"
WinWait, ahk_exe EADesktop.exe 
Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"
WinWait, ahk_exe MassEffect.exe
WinWaitClose, ahk_exe MassEffect.exe
WinClose, ahk_exe EADesktop.exe
ExitApp

 

 

Back at my main PC now and I do have the EA launcher on there. I tested out both of these commands, WinClose and Process, Close, they both work closing EADesktop.exe. So with that said, best to use the WinClose option since it's proven to work and the standard graceful way of closing a window or app

Posted
2 hours ago, skizzosjt said:

sorry that one is on me. clearly did NOT double check my work 🤦‍♂️ I left a line out and flip flopped the intended command. I did the following:

Run the storefront launcher, wait for launcher to exist, run the game, wait for game to exist, wait for the launcher to close....lol makes no sense

 

here is what I intended to do:

Run the storefront launcher, wait for launcher to exist, run the game, wait for game to exist, wait for game to not exist, close the launcher.

Run, "C:\Program Files\Electronic Arts\EA Desktop\EA Desktop\EADesktop.exe"
WinWait, ahk_exe EADesktop.exe 
Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"
WinWait, ahk_exe MassEffect.exe
WinWaitClose, ahk_exe MassEffect.exe
WinClose, ahk_exe EADesktop.exe
ExitApp

 

 

Back at my main PC now and I do have the EA launcher on there. I tested out both of these commands, WinClose and Process, Close, they both work closing EADesktop.exe. So with that said, best to use the WinClose option since it's proven to work and the standard graceful way of closing a window or app

Then it's something with my set-up because I am not having any luck.

 

Here I made a video, let me know if there are any clues to glean off of it

 

 

Posted

What happens if you have just the line Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"

That is, not start EADesktop?  Maybe it's different with Mass Effect, but my gotg.exe is able to launch this way.  Though I did notice that after exiting, it leaves EALauncher.exe running in the background.  Which is only an issue "because it's there".

  • Haha 1
Posted

I don't really use EA often at all. I have two games on it, which are actually Steam games but it still launches the EA launcher too (boy that is a pet peeve of mine - only one launcher, please lol) Last game I would have played a few times was Star Wars Jedi Knight (over a year ago) and I don't ever recall the EA launcher popping back up after exiting the game. I had to update the launcher to test this and it def does pop back up every time I exit a game now. So seems like new behavior for their latest app version.

19 minutes ago, JoeViking245 said:

What happens if you have just the line Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"

That is, not start EADesktop?  Maybe it's different with Mass Effect, but my gotg.exe is able to launch this way.  Though I did notice that after exiting, it leaves EALauncher.exe running in the background.  Which is only an issue "because it's there".

yea def can launch these games directly, but same here, the launcher window is restored at game exit each time.

 

@Bucky can you also try using AHK to close the EA launcher? create another script with just a single line to close this window. put it on your desktop and double click it to run it from there. if this doesn't close the window then we know something def going on on your end preventing it from working

WinClose, ahk_exe EADesktop.exe

 

that pop up about needing admin privileges is suspicious but from what I can tell it's doing that to the game, not the launcher. AHK cannot close apps/windows that have admin privileges unless the script is also launched with admin privileges. but we're only using AHK to close the launcher rather than the game.

 

if still not working, as a last ditch effort you can try making the script run with admin privileges but this opens another can of worms because you would need to always click yes on the UAC prompt to allow the script to use admin privileges so not exactly fully automated

Here is the instructions from AHK docs. you just add this at start of a script

https://www.autohotkey.com/docs/v1/lib/Run.htm#RunAs

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}
WinClose, ahk_exe EADesktop.exe

 

Posted
2 hours ago, skizzosjt said:

yea def can launch these games directly, but same here, the launcher window is restored at game exit each time.

Hmm... mine goes to and stays in the System Tray.

And it does that (system tray) too when I had LaunchBox import the games and launch them that way (as noted above under "taking the easy way out").

Posted (edited)

Huh, abscent Mass Effect, both apps close it, just like you guys said. When I boot-up just EA App and run script it closes.

2 hours ago, JoeViking245 said:

What happens if you have just the line Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"

That is, not start EADesktop?  Maybe it's different with Mass Effect, but my gotg.exe is able to launch this way.  

Like this?

Run, "C:\Program Files\EA Games\Mass Effect\Binaries\MassEffect.exe"
WinWait, ahk_exe MassEffect.exe
WinWaitClose, ahk_exe MassEffect.exe
WinClose, ahk_exe EADesktop.exe
ExitApp

 

Tried it with only that way removing the other line about EADesktop.exe, it still would not close.

2 hours ago, skizzosjt said:

I don't really use EA often at all. I have two games on it, which are actually Steam games but it still launches the EA launcher too (boy that is a pet peeve of mine - only one launcher, please lol) Last game I would have played a few times was Star Wars Jedi Knight (over a year ago) and I don't ever recall the EA launcher popping back up after exiting the game. I had to update the launcher to test this and it def does pop back up every time I exit a game now. So seems like new behavior for their latest app version.

yea def can launch these games directly, but same here, the launcher window is restored at game exit each time.

 

@Bucky can you also try using AHK to close the EA launcher? create another script with just a single line to close this window. put it on your desktop and double click it to run it from there. if this doesn't close the window then we know something def going on on your end preventing it from working

WinClose, ahk_exe EADesktop.exe

 

that pop up about needing admin privileges is suspicious but from what I can tell it's doing that to the game, not the launcher. AHK cannot close apps/windows that have admin privileges unless the script is also launched with admin privileges. but we're only using AHK to close the launcher rather than the game.

 

if still not working, as a last ditch effort you can try making the script run with admin privileges but this opens another can of worms because you would need to always click yes on the UAC prompt to allow the script to use admin privileges so not exactly fully automated

Here is the instructions from AHK docs. you just add this at start of a script

https://www.autohotkey.com/docs/v1/lib/Run.htm#RunAs

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}
WinClose, ahk_exe EADesktop.exe

 

Let me ask this, what's the line to combine your last code set with launching Mass Effect?  Maybe that might do it, I feel like we're getting close.

Edited by Bucky
Posted
1 minute ago, Bucky said:

Tried it with only that way removing the other line about EADesktop.exe, it still would not close.

Is it really EADesktop.exe that still there? Or EALauncher.exe?  On mine, 'Desktop' never appears. Only 'Launcher' does. And it's hidden in the System Tray.  Is your setup, your legit personal login? Or a hacked variant [that's acting differently than ours]?  If it's the latter, then probably takes different troubleshooting techniques.

Posted (edited)

Hi, thanks again for all your help regardless of if we resolve this or not

8 minutes ago, JoeViking245 said:

Is it really EADesktop.exe that still there? Or EALauncher.exe?  On mine, 'Desktop' never appears. Only 'Launcher' does. And it's hidden in the System Tray.  Is your setup, your legit personal login? Or a hacked variant [that's acting differently than ours]?  If it's the latter, then probably takes different troubleshooting techniques.

It's a legit login, the EA App was left untouched. The only thing different is the game itself due to mods only for the game. The app was updated under normal settings to never update game, otherwise it will break the mod. 

 

Replaced EADesktop.exe with EALauncher.exe in the ahk code, it's a no go. It wouldn't even close window and send the app to system tray :(

Edited by Bucky

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...