Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- Fix-BattlEye-Generic.ps1
- ----------------------------------------------------------
- Purpose:
- Generic BattlEye reset to fix BSODs caused by BEDaisy.sys across ANY BattlEye game.
- - Stops/removes BEService
- - Deletes BEDaisy.sys
- - Cleans BattlEye folders for selected games (Steam/Epic)
- - Optional "Quick Reset": driver + AppData only (no game folder touch)
- - NO Steam/Epic verify here (do it manually per game)
- Works on: Windows 10/11 (x64)
- Requirements: Run as Administrator
- Notes:
- - Safe by default: you PICK which games to clean (or "All").
- - Keeps other non-selected games’ BattlEye intact.
- - After running, open your game launcher and verify files to reinstall BE.
- #>
- # ===== Config / Logging =====
- $LogFile = "$PSScriptRoot\BattlEye_Fix_$(Get-Date -Format 'yyyyMMdd_HHmmss').log"
- function Write-Log {
- param([string]$Message, [string]$Color = "White")
- $ts = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
- $line = "[$ts] $Message"
- Add-Content -Path $LogFile -Value $line
- Write-Host $Message -ForegroundColor $Color
- }
- # ===== Elevation check =====
- $principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
- if (-not $principal.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) {
- Write-Host "[!] Please run this script as Administrator. Relaunching..." -ForegroundColor Yellow
- Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
- exit
- }
- Clear-Host
- Write-Host "=== Generic BattlEye (BEDaisy.sys) Reset ===" -ForegroundColor Cyan
- Write-Host "Log: $LogFile`n" -ForegroundColor DarkGray
- # ===== Helpers =====
- function Stop-LaunchersAndGames {
- $names = @(
- "GTA5","GTAVLauncher","FiveM","Steam","SteamService",
- "RockstarGamesLauncher","EpicGamesLauncher","SocialClubHelper",
- "FortniteClient-Win64-Shipping","FortniteLauncher",
- "DayZ","ShooterGame","Tarkov","R5Apex","RainbowSix","arma3_x64"
- )
- foreach ($n in $names) {
- Get-Process -Name $n -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
- }
- }
- function Remove-Target {
- param([string]$Path)
- if (-not (Test-Path $Path)) { return }
- try {
- # Remove read-only and take ownership if needed
- try { attrib -R $Path -ErrorAction SilentlyContinue | Out-Null } catch {}
- try { takeown.exe /f "$Path" /a /r /d y | Out-Null } catch {}
- try { icacls.exe "$Path" /grant "*S-1-5-32-544:(F)" /T /C | Out-Null } catch {}
- Remove-Item -LiteralPath $Path -Recurse -Force -ErrorAction Stop
- Write-Log "Removed: $Path" "Green"
- } catch {
- Write-Log "Failed to remove: $Path ($_)" "Yellow"
- }
- }
- function Get-SteamLibraries {
- $libs = @()
- $reg = "HKLM:\SOFTWARE\WOW6432Node\Valve\Steam"
- if (Test-Path $reg) {
- $steamPath = (Get-ItemProperty -Path $reg -Name InstallPath -ErrorAction SilentlyContinue).InstallPath
- if ($steamPath) { $libs += $steamPath }
- $vdf = Join-Path $steamPath "steamapps\libraryfolders.vdf"
- if (Test-Path $vdf) {
- (Get-Content $vdf) -match '"path"\s+"([^"]+)"' | ForEach-Object {
- $m = [regex]::Match($_, '"path"\s+"([^"]+)"')
- if ($m.Success) { $libs += $m.Groups[1].Value }
- }
- }
- }
- $libs | Select-Object -Unique
- }
- function Get-EpicRoots {
- # Common Epic install roots (best-effort)
- @(
- "$env:ProgramFiles\Epic Games",
- "$env:ProgramFiles(x86)\Epic Games",
- "C:\Epic Games",
- "D:\Epic Games",
- "E:\Epic Games"
- ) | Where-Object { Test-Path $_ } | Select-Object -Unique
- }
- function Find-BattlEyeFolders {
- # Returns objects with GameName and BEPath
- $results = @()
- # Steam
- foreach ($lib in Get-SteamLibraries) {
- $common = Join-Path $lib "steamapps\common"
- if (Test-Path $common) {
- try {
- $beDirs = Get-ChildItem -LiteralPath $common -Directory -Recurse -ErrorAction SilentlyContinue |
- Where-Object { $_.Name -ieq "BattlEye" }
- foreach ($dir in $beDirs) {
- $game = Split-Path $dir.Parent.FullName -Leaf
- $results += [pscustomobject]@{
- Platform = "Steam"
- GameName = $game
- BEPath = $dir.FullName
- }
- }
- } catch {}
- }
- }
- # Epic (shallow scan: BattlEye folder directly under each game)
- foreach ($root in Get-EpicRoots) {
- try {
- $games = Get-ChildItem -LiteralPath $root -Directory -ErrorAction SilentlyContinue
- foreach ($g in $games) {
- $be = Join-Path $g.FullName "BattlEye"
- if (Test-Path $be) {
- $results += [pscustomobject]@{
- Platform = "Epic"
- GameName = $g.Name
- BEPath = $be
- }
- }
- }
- } catch {}
- }
- # De-dup by path
- $results | Sort-Object BEPath -Unique
- }
- function Clean-AppDataBattlEye-AllUsers {
- Write-Log "Cleaning AppData BattlEye (all users)..." "Yellow"
- Get-ChildItem "C:\Users" -Directory -ErrorAction SilentlyContinue | ForEach-Object {
- $paths = @(
- "$($_.FullName)\AppData\Local\BattlEye",
- "$($_.FullName)\AppData\Roaming\BattlEye"
- )
- foreach ($p in $paths) { if (Test-Path $p) { Remove-Target $p } }
- }
- }
- function Driver-Reset {
- Write-Log "Stopping & deleting BEService..." "Yellow"
- sc.exe stop BEService | Out-Null
- Start-Sleep -Milliseconds 500
- sc.exe delete BEService | Out-Null
- Start-Sleep -Milliseconds 300
- $driverCandidates = @(
- "$env:WINDIR\System32\drivers\BEDaisy.sys",
- "$env:WINDIR\SysWOW64\BEDaisy.sys"
- )
- foreach ($d in $driverCandidates) {
- if (Test-Path $d) { Remove-Target $d }
- }
- Clean-AppDataBattlEye-AllUsers
- }
- # ===== Main Flow =====
- Write-Log "Stopping running launchers/games..." "Gray"
- Stop-LaunchersAndGames
- Start-Sleep -Seconds 1
- Write-Log "Scanning for BattlEye folders in Steam/Epic..." "Gray"
- $found = Find-BattlEyeFolders
- if (-not $found -or $found.Count -eq 0) {
- Write-Log "No BattlEye folders found in known locations. You can still run a DRIVER-ONLY reset." "Yellow"
- }
- Write-Host ""
- Write-Host "Choose an action:" -ForegroundColor Cyan
- Write-Host " 1) Clean SELECTED games (remove BattlEye folder for chosen titles)"
- Write-Host " 2) Clean ALL detected games (remove BattlEye across all listed titles)"
- Write-Host " 3) QUICK RESET (Driver + AppData only, do NOT touch game folders)"
- Write-Host " 4) Exit"
- $action = Read-Host "Enter 1-4"
- switch ($action) {
- "1" {
- if (-not $found -or $found.Count -eq 0) {
- Write-Log "No games to select. Use QUICK RESET (3)." "Red"
- break
- }
- Write-Host "`nDetected BattlEye folders:" -ForegroundColor Cyan
- for ($i=0; $i -lt $found.Count; $i++) {
- Write-Host (" [{0}] {1} - {2}" -f $i, $found[$i].Platform, $found[$i].GameName)
- Write-Host (" {0}" -f $found[$i].BEPath) -ForegroundColor DarkGray
- }
- $sel = Read-Host "`nEnter comma-separated indexes to clean (e.g. 0,2,3)"
- $idx = $sel -split "," | ForEach-Object { $_.Trim() } | Where-Object { $_ -match '^\d+$' } | ForEach-Object { [int]$_ } | Where-Object { $_ -ge 0 -and $_ -lt $found.Count }
- if (-not $idx -or $idx.Count -eq 0) { Write-Log "No valid selection. Aborting." "Yellow"; break }
- Write-Log "Running DRIVER RESET first..." "Gray"
- Driver-Reset
- foreach ($i in $idx) {
- Write-Log "Removing BattlEye for: $($found[$i].Platform) - $($found[$i].GameName)" "Yellow"
- Remove-Target $found[$i].BEPath
- }
- Write-Log "Done. Please VERIFY files in your launcher for the games you cleaned." "Cyan"
- }
- "2" {
- if (-not $found -or $found.Count -eq 0) {
- Write-Log "No games detected. Use QUICK RESET (3)." "Red"
- break
- }
- Write-Log "Running DRIVER RESET first..." "Gray"
- Driver-Reset
- foreach ($item in $found) {
- Write-Log "Removing BattlEye for: $($item.Platform) - $($item.GameName)" "Yellow"
- Remove-Target $item.BEPath
- }
- Write-Log "Done. Please VERIFY files in your launcher for ALL cleaned games." "Cyan"
- }
- "3" {
- Write-Log "Performing QUICK RESET (Driver + AppData only)..." "Yellow"
- Driver-Reset
- Write-Log "Quick reset complete. Start your game to let BattlEye reinstall, or run a manual verify." "Cyan"
- }
- default {
- Write-Log "Exit." "Gray"
- }
- }
- Write-Log "Script finished."
Advertisement
Add Comment
Please, Sign In to add comment