Stop EpicGamesLauncher process when closing game that uses it.
If you add a non-Steam game to your library that uses a secondary game service launcher like Epic Games, Blizzard, or GOG, then you may have used a guide such as Ducain's from here: https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=2476375614
This is one of the best guides for launching games from the Epic Games Launcher cleanly. I just had to make my Steam run as Administrator to avoid the User Account Control popups from stopping the stream for Steam Link when trying to play on my Nvidia Shield TV across the house. The biggest problem that I have yet to see solved is that you have to go to the computer and manually exit the game launchers before you can launch another game from that service through Steam.

I found a way to auto-kill the EpicGamesLauncher process after exiting out of games so that I don't have to manually shut it down. It will kill the game launcher process no matter how the game was launched though. I have only tried with GTA V since that is the only game i have mapped through steam for now and I use Steam Link on my Nvidia Shield TV. If I ever wanted to launch another Epic game after quitting one, this is also a big help. Maybe if it works well enough, @Ducain can add it to his Guide with better formatting and just credit my post so that it can reach many more people.

Using some help from Google Gemini I was able to come up with a Powershell script that kills the EpicGamesLauncher 20 seconds after calling the script.

To Create the script:

- Open notepad and enter

# Terminate EpicGamesLauncher.exe
$processName = "EpicGamesLauncher"
$waitTimeSeconds = 20 # Define the wait time

# Check if the process is running before attempting to stop it
if (Get-Process -Name $processName -ErrorAction SilentlyContinue) {
Write-Host "$processName is running. Waiting $waitTimeSeconds seconds before termination..."
Start-Sleep -Seconds $waitTimeSeconds # This is the 30-second wait

# After waiting, check again in case it closed naturally during the wait
if (Get-Process -Name $processName -ErrorAction SilentlyContinue) {
Stop-Process -Name $processName -Force -ErrorAction SilentlyContinue
Write-Host "$processName terminated successfully after wait."
} else {
Write-Host "$processName closed naturally during the wait time."
}
} else {
Write-Host "$processName is not running."
}

- Change the 20 after
$waitTimeSeconds =
to however many seconds you want to wait before killing the launcher to allow cloud saving and such to finish. Now save the file as "TerminateEpicGamesLauncher.ps1". I created a game-scripts folder in my C:\ drive and placed the script there.

Install Sysmon:

- Sysmon will monitor the creation and termination of processes on your system so it knows when programs start, and - what we want to especially know - when they stop.
- Go to https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon and click the link in the middle of the page that says "Download Sysmon". Extract the zip file in your Downloads folder.
- You should now have a directory at "C:\Users\USERNAME\Downloads\Sysmon" (where USERNAME is your login username) with a text file and 3 sysmon.exe variants.
- Click the Windows/Start button and type in cmd, then right-click Command Prompt in the list and choose Run as Administrator.
- Type
cd C:\Users\USERNAME\Downloads\Sysmon
(where USERNAME is your current login username).
- Then, per the Sysmon instructions, type
.\sysmon -accepteula -i
- We can now monitor when the game.exe file of our choice stops so that we can send a command to run our script we created earlier which will also shutdown the game launcher.

Setup Task Scheduler:

- Now that we have a way to monitor the stopping of our game, and we have a script ready and waiting to stop the game launcher, we need a way to bring it together. Queue - Windows Task Scheduler.
- Click on Windows/Start button and type task scheduler, then click on Task Scheduler.
- In the left pane, right-click Task Scheduler Library and select create task.
- On the General tab, give it an identifying/unique name. (I choose "GTAV Stop EpicGamesLauncher" since my task is going to watch for the stopping of GTAV game.exe and then run script to stop EpicGamesLauncher. This will make it easier to identify the tasks if you create them for more than one game.)
- Under Security options "When running the task, use the following user account:", you will probably want to leave it at the default current user, or you can select a different user. Below that, select "Run whether user is logged on or not" and check the box for "Run with highest privileges", then in the drop down select Windows 10.
- On the Triggers Tab, click on New at the bottom of the page, you will get a popup window
- At the Begin the task dropdown select "On an Event"
- Click Custom on the left side and then Click Edit Event Filter Button
- You will see another popup with a Filter tab and XML tab. Click on the XML tab and then click on the "Edit query manually" checkbox at the bottom. You will get a popup about not being able to use the Filter tab if you continue - Click "Yes"
- Paste in the following information to monitor for the closing of a specific file.

<QueryList>
<Query Id="0" Path="Microsoft-Windows-Sysmon/Operational">
<Select Path="Microsoft-Windows-Sysmon/Operational">
*[System[(EventID=5)]]
and
*[EventData[Data[@Name='Image']='D:\Games\GTAVEnhanced\PlayGTAV.exe']]
</Select>
</Query>
</QueryList>

- Change the path D:\Games\GTAVEnhanced\PlayGTAV.exe to the executable that runs when you are playing the game. You can also look for the path information in the Event Viewer under "Applications and Services Logs > Microsoft > Windows > Sysmon > Operational" and look for Event ID 5 entries then find the Image: line under the General section.
- Click OK at the bottom of the Edit Event Filter popup
- Make sure Enabled is checked at the bottom of the Edit Trigger popup and then click OK
- Now we are back on our task editor, select the Actions tab and click on New at the bottom
- For the Action drop down menu, choose Start a program
- in the Program/script field type powershell.exe (do not click on Browse)
- in the Add arguments (optional): field, type (or copy/paste) the following:
-NoProfile -ExecutionPolicy Bypass -File "C:\game_scripts\TerminateEpicGamesLauncher.ps1"
where C:\game_scripts is the path to the powershell script we created in step 1, and TerminateEpicGamesLauncher.ps1 is the name of the powershell script we created in step 1. Then click OK at the bottom of the popup.
- Select the Conditions tab in our task editor and make sure all boxes are unchecked.
- Select the Settings tab and make sure there is a check for "Allow task to be run on demand", "Stop the task if it runs longer than:" (and set a time of 1 hour in the drop down), and "If the running task does not end when requested, force it to stop". Then in the last dropdown at the bottom chose "Do not start a new instance" and click OK.
- You will get a popup to authenticate the user you selected at the beginning of the task editor on the General tab.

Now you can test it out and see. You should find that once you close the game defined trigger query of Task Scheduler, your EpicGamesLauncher process should automatically stop/close after about 20 seconds.

If it doesn't work, troubleshoot your path for the game you are monitoring, or the path to the script on the Actions tab of the task scheduler.
Last edited by Terydan; 25 May @ 2:37am
< >
Showing 1-2 of 2 comments
Just found this today while looking into using steam to launch epic (Got UWPHook for Gamepass already). Excited to put it to use beyond testing.

But, is there a way to minimize the powershell window on launch, or run it silently, or something? Seeing a huge blue window popup when closing the game is a bit jarring.
Terydan 2 Jun @ 1:06pm 
It should run silently. I have been using it daily since posting and not had any issues. I believe that the arguments specified when executing the script in Task Scheduler are what makes it run silent. The script itself does directly call within to proceed silently. I can only think to make sure the arguments are correct and that the script doesn't have any errors that would make it open an active window. Maybe making sure "Run with highest privileges" is checked in the task scheduler.
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: 25 May @ 2:31am
Posts: 2