Skip to content

Instantly share code, notes, and snippets.

@rstewa
Created January 8, 2023 08:12
Show Gist options
  • Save rstewa/67a8d9bbf65b613630dc8a1ec58d18cd to your computer and use it in GitHub Desktop.
Save rstewa/67a8d9bbf65b613630dc8a1ec58d18cd to your computer and use it in GitHub Desktop.
Disable Epic Games Overlay for the Epic Games Launcher
#requires -version 2
<#
.NOTES
Version: 1.0
Author: Ryan Stewart
Creation Date: 06/12/22
Purpose/Change: Disable EpicGames bullshit overlay
#>
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
#Set Error Action to Silently Continue
$ErrorActionPreference = "SilentlyContinue"
#----------------------------------------------------------[Declarations]----------------------------------------------------------
#Script Version
$sScriptVersion = "1.0"
#Log File Info
$sLogPath = "C:\Windows\Temp"
$sLogName = "Disable-EpicGamesOverlay.log"
$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName
#global variables
$x86 = ${Env:ProgramFiles(x86)}
$eosDir = "${x86}\Epic Games\Launcher\Portal\Extras\Overlay"
$eosPath_Win32 = "${eosDir}\EOSOverlayRenderer-Win32-Shipping.exe"
$eosPath_Win64 = "${eosDir}\EOSOverlayRenderer-Win64-Shipping.exe"
$eosPath_Win32_NewName = "${eosPath_Win32}.bullshit"
$eosPath_Win64_NewName = "${eosPath_Win64}.bullshit"
# notification variables
$toastTitle = "Disable-EpicGamesOverlay.ps1"
$message = "Epic Games EOSOverlay disabled successfully!"
$alreadyDisabledMessage = "Epic Games EOSOverlay disabled successfully!"
$errorMessage = "Disable-EpicGamesOverlay encountered an error: Check log file -> 'C:\Windows\Temp\Disable-EpicGamesOverlay.log'"
$toastTitle2 = "Enable-EpicGamesOverlay.ps1"
$message2 = "Epic Games EOSOverlay enabled successfully!"
$overlayExisted = 0
#-----------------------------------------------------------[Functions]------------------------------------------------------------
# todo
# $Regex = "^((\\\\[a-zA-Z0-9-]+\\[a-zA-Z0-9`~!@#$%^&(){}'._-]+([ ]+[a-zA-Z0-9`~!@#$%^&(){}'._-]+)*)|([a-zA-Z]:))(\\[^ \\/:*?""<>|]+([ ]+[^ \\/:*?""<>|]+)*)*\\?$"
# $Paths = @("\\Server", "\\Server\Share", "C:\Windows", "Some stuff")
#
# foreach ($Path in $Paths) {
# if ($Path -Match $Regex) {
# Write-Host "$Path"
# }
# }
Function Disable-EpicGamesOverlay {
Param()
Begin {
Log-Write -LogPath $sLogFile -LineValue "Renaming 'EOSOverlayRenderer-Win32-Shipping.exe' and 'EOSOverlayRenderer-Win64-Shipping.exe'..."
}
Process {
Try {
if (Test-Path $eosPath_Win32) {
$overlayExisted = 1
# delete old .bullshit file if exists
if (Test-Path $eosPath_Win32_NewName) {
Remove-Item $eosPath_Win32_NewName
}
# change overlay .exe file extension to .bullshit (prevents epic from running it)
Rename-Item -Path $eosPath_Win32 -NewName $eosPath_Win32_NewName
}
if (Test-Path $eosPath_Win64) {
$overlayExisted = 1
# delete old .bullshit file if exists
if (Test-Path $eosPath_Win64_NewName) {
Remove-Item $eosPath_Win64_NewName
}
# change overlay .exe file extension to .bullshit (prevents epic from running it)
Rename-Item -Path $eosPath_Win64 -NewName $eosPath_Win64_NewName
}
if ($overlayExisted -eq 1) {
Show-Notification $toastTitle $message
}
else {
Show-Notification $toastTitle $alreadyDisabledMessage
}
}
Catch {
Show-Notification $toastTitle $errorMessage
Log-Error -LogPath $sLogFile -ErrorDesc $_.Exception -ExitGracefully $True
Break
}
}
End {
If ($?) {
Log-Write -LogPath $sLogFile -LineValue $message
Log-Write -LogPath $sLogFile -LineValue " "
# send user toast notification
Show-Notification $toastTitle $message
}
}
}
Function Enable-EpicGamesOverlay {
Param()
Begin {
Log-Write -LogPath $sLogFile -LineValue "Renaming 'EOSOverlayRenderer-Win32-Shipping.exe.bullshit' and 'EOSOverlayRenderer-Win64-Shipping.exe.bullshit'..."
}
Process {
Try {
if (Test-Path $eosPath_Win32_NewName) {
$overlayExisted = 1
Rename-Item -Path $eosPath_Win32_NewName -NewName $eosPath_Win32
}
if (Test-Path $eosPath_Win64_NewName) {
$overlayExisted = 1
Rename-Item -Path $eosPath_Win64_NewName -NewName $eosPath_Win64
}
if ($overlayExisted -eq 1) {
Show-Notification $toastTitle2 $message2
}
else {
Show-Notification $toastTitle $alreadyDisabledMessage
}
}
Catch {
Show-Notification $toastTitle $errorMessage
Log-Error -LogPath $sLogFile -ErrorDesc $_.Exception -ExitGracefully $True
Break
}
}
End {
If ($?) {
Log-Write -LogPath $sLogFile -LineValue $message
Log-Write -LogPath $sLogFile -LineValue " "
# send user toast notification
Show-Notification $toastTitle $message
}
}
}
#-------------------------------------------[Logging functions from @9to5IT on GitHub]---------------------------------------------
Function Log-Start {
<#
.SYNOPSIS
Creates log file
.DESCRIPTION
Creates log file with path and name that is passed. Checks if log file exists, and if it does deletes it and creates a new one.
Once created, writes initial logging data
.PARAMETER LogPath
Mandatory. Path of where log is to be created. Example: C:\Windows\Temp
.PARAMETER LogName
Mandatory. Name of log file to be created. Example: Test_Script.log
.PARAMETER ScriptVersion
Mandatory. Version of the running script which will be written in the log. Example: 1.5
.INPUTS
Parameters above
.OUTPUTS
Log file created
.NOTES
Version: 1.0
Author: Luca Sturlese
Creation Date: 10/05/12
Purpose/Change: Initial function development
Version: 1.1
Author: Luca Sturlese
Creation Date: 19/05/12
Purpose/Change: Added debug mode support
.EXAMPLE
Log-Start -LogPath "C:\Windows\Temp" -LogName "Test_Script.log" -ScriptVersion "1.5"
#>
[CmdletBinding()]
Param ([Parameter(Mandatory = $true)][string]$LogPath, [Parameter(Mandatory = $true)][string]$LogName, [Parameter(Mandatory = $true)][string]$ScriptVersion)
Process {
$sFullPath = $LogPath + "\" + $LogName
#Check if file exists and delete if it does
If ((Test-Path -Path $sFullPath)) {
Remove-Item -Path $sFullPath -Force
}
#Create file and start logging
New-Item -Path $LogPath -Value $LogName -ItemType File
Add-Content -Path $sFullPath -Value "***************************************************************************************************"
Add-Content -Path $sFullPath -Value "Started processing at [$([DateTime]::Now)]."
Add-Content -Path $sFullPath -Value "***************************************************************************************************"
Add-Content -Path $sFullPath -Value ""
Add-Content -Path $sFullPath -Value "Running script version [$ScriptVersion]."
Add-Content -Path $sFullPath -Value ""
Add-Content -Path $sFullPath -Value "***************************************************************************************************"
Add-Content -Path $sFullPath -Value ""
#Write to screen for debug mode
Write-Debug "***************************************************************************************************"
Write-Debug "Started processing at [$([DateTime]::Now)]."
Write-Debug "***************************************************************************************************"
Write-Debug ""
Write-Debug "Running script version [$ScriptVersion]."
Write-Debug ""
Write-Debug "***************************************************************************************************"
Write-Debug ""
}
}
Function Log-Write {
<#
.SYNOPSIS
Writes to a log file
.DESCRIPTION
Appends a new line to the end of the specified log file
.PARAMETER LogPath
Mandatory. Full path of the log file you want to write to. Example: C:\Windows\Temp\Test_Script.log
.PARAMETER LineValue
Mandatory. The string that you want to write to the log
.INPUTS
Parameters above
.OUTPUTS
None
.NOTES
Version: 1.0
Author: Luca Sturlese
Creation Date: 10/05/12
Purpose/Change: Initial function development
Version: 1.1
Author: Luca Sturlese
Creation Date: 19/05/12
Purpose/Change: Added debug mode support
.EXAMPLE
Log-Write -LogPath "C:\Windows\Temp\Test_Script.log" -LineValue "This is a new line which I am appending to the end of the log file."
#>
[CmdletBinding()]
Param ([Parameter(Mandatory = $true)][string]$LogPath, [Parameter(Mandatory = $true)][string]$LineValue)
Process {
Add-Content -Path $LogPath -Value $LineValue
#Write to screen for debug mode
Write-Debug $LineValue
}
}
Function Log-Error {
<#
.SYNOPSIS
Writes an error to a log file
.DESCRIPTION
Writes the passed error to a new line at the end of the specified log file
.PARAMETER LogPath
Mandatory. Full path of the log file you want to write to. Example: C:\Windows\Temp\Test_Script.log
.PARAMETER ErrorDesc
Mandatory. The description of the error you want to pass (use $_.Exception)
.PARAMETER ExitGracefully
Mandatory. Boolean. If set to True, runs Log-Finish and then exits script
.INPUTS
Parameters above
.OUTPUTS
None
.NOTES
Version: 1.0
Author: Luca Sturlese
Creation Date: 10/05/12
Purpose/Change: Initial function development
Version: 1.1
Author: Luca Sturlese
Creation Date: 19/05/12
Purpose/Change: Added debug mode support. Added -ExitGracefully parameter functionality
.EXAMPLE
Log-Error -LogPath "C:\Windows\Temp\Test_Script.log" -ErrorDesc $_.Exception -ExitGracefully $True
#>
[CmdletBinding()]
Param ([Parameter(Mandatory = $true)][string]$LogPath, [Parameter(Mandatory = $true)][string]$ErrorDesc, [Parameter(Mandatory = $true)][boolean]$ExitGracefully)
Process {
Add-Content -Path $LogPath -Value "Error: An error has occurred [$ErrorDesc]."
#Write to screen for debug mode
Write-Debug "Error: An error has occurred [$ErrorDesc]."
#If $ExitGracefully = True then run Log-Finish and exit script
If ($ExitGracefully -eq $True) {
Log-Finish -LogPath $LogPath
Break
}
}
}
Function Log-Finish {
<#
.SYNOPSIS
Write closing logging data & exit
.DESCRIPTION
Writes finishing logging data to specified log and then exits the calling script
.PARAMETER LogPath
Mandatory. Full path of the log file you want to write finishing data to. Example: C:\Windows\Temp\Test_Script.log
.PARAMETER NoExit
Optional. If this is set to True, then the function will not exit the calling script, so that further execution can occur
.INPUTS
Parameters above
.OUTPUTS
None
.NOTES
Version: 1.0
Author: Luca Sturlese
Creation Date: 10/05/12
Purpose/Change: Initial function development
Version: 1.1
Author: Luca Sturlese
Creation Date: 19/05/12
Purpose/Change: Added debug mode support
Version: 1.2
Author: Luca Sturlese
Creation Date: 01/08/12
Purpose/Change: Added option to not exit calling script if required (via optional parameter)
.EXAMPLE
Log-Finish -LogPath "C:\Windows\Temp\Test_Script.log"
.EXAMPLE
Log-Finish -LogPath "C:\Windows\Temp\Test_Script.log" -NoExit $True
#>
[CmdletBinding()]
Param ([Parameter(Mandatory = $true)][string]$LogPath, [Parameter(Mandatory = $false)][string]$NoExit)
Process {
Add-Content -Path $LogPath -Value ""
Add-Content -Path $LogPath -Value "***************************************************************************************************"
Add-Content -Path $LogPath -Value "Finished processing at [$([DateTime]::Now)]."
Add-Content -Path $LogPath -Value "***************************************************************************************************"
#Write to screen for debug mode
Write-Debug ""
Write-Debug "***************************************************************************************************"
Write-Debug "Finished processing at [$([DateTime]::Now)]."
Write-Debug "***************************************************************************************************"
#Exit calling script if NoExit has not been specified or is set to False
If (!($NoExit) -or ($NoExit -eq $False)) {
Exit
}
}
}
#--------[Toast Notification Function from @dend on GitHub (https://gist.github.com/dend/5ae8a70678e3a35d02ecd39c12f99110)]--------
function Show-Notification {
<#
.SYNOPSIS
Sends toast notification. From @dend on GitHub (https://gist.github.com/dend/5ae8a70678e3a35d02ecd39c12f99110)
.DESCRIPTION
Sends toast notification. From @dend on GitHub (https://gist.github.com/dend/5ae8a70678e3a35d02ecd39c12f99110)
.PARAMETER ToastTitle
Title of the toast notification to send
.PARAMETER ToastTitle
Text of the toast notification to send
.INPUTS
Parameters above
.OUTPUTS
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
.NOTES
Version: 1.0
Author: <Name>
Creation Date: <Date>
Purpose/Change: Initial script development
.EXAMPLE
Show-Notification "Example Title" "Example Text"
#>
[cmdletbinding()]
Param (
[string]
$ToastTitle,
[string]
[parameter(ValueFromPipeline)]
$ToastText
)
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$Template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
$RawXml = [xml] $Template.GetXml()
($RawXml.toast.visual.binding.text | where { $_.id -eq "1" }).AppendChild($RawXml.CreateTextNode($ToastTitle)) > $null
($RawXml.toast.visual.binding.text | where { $_.id -eq "2" }).AppendChild($RawXml.CreateTextNode($ToastText)) > $null
$SerializedXml = New-Object Windows.Data.Xml.Dom.XmlDocument
$SerializedXml.LoadXml($RawXml.OuterXml)
$Toast = [Windows.UI.Notifications.ToastNotification]::new($SerializedXml)
$Toast.Tag = "PowerShell"
$Toast.Group = "PowerShell"
$Toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(1)
$Notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("PowerShell")
$Notifier.Show($Toast);
}
#-----------------------------------------------------------[Execution]------------------------------------------------------------
Log-Start -LogPath $sLogPath -LogName $sLogName -ScriptVersion $sScriptVersion
Disable-EpicGamesOverlay
# Enable-EpicGamesOverlay
Log-Finish -LogPath $sLogFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment