; deletes rblx cookie file ; Replace 'black' below with your Windows username before using. #SingleInstance Force Persistent RobloxExes := [ "RobloxPlayerBeta.exe", "RobloxPlayerLauncher.exe", "RobloxStudioBeta.exe" ] LeftoverExes := [ "RobloxCrashHandler.exe", "RobloxPlayerLauncher.exe" ] ; Change your user here: CookieFile := "C:\Users\black\AppData\Local\Roblox\LocalStorage\RobloxCookies.dat" LogFile := A_ScriptDir "\FkRoblox.log" AllowElevation := true robloxRunning := false A_TrayMenu.Add("Cleanup Now", DoManualCleanup) A_TrayMenu.Default := "Cleanup Now" A_TrayMenu.Tip := "Fk Roblox (Right-click for options)" ^!c::DoManualCleanup() if (A_IsAdmin && HasCleanupFlag()) { DoNotify("Admin cleanup in progress") Log("Admin cleanup mode triggered") KillLeftovers() Sleep 2000 DeleteCookies(false) } if !AnyRobloxRunning() { Log("First run: Roblox not detected in background. Performing cleanup.") DoNotify("Roblox not running. Performing cleanup.") KillLeftovers() Sleep 1000 DeleteCookies(true) } else if IsRobloxTrayOnly() { Log("First run: Roblox running only in background/system tray. Killing for cleanup.") DoNotify("Roblox in tray. Closing and cleaning up...") for exe in RobloxExes { while ProcessExist(exe) { try ProcessClose exe Sleep 300 } Log("Closed (tray) Roblox instance: " exe) } Sleep 1000 KillLeftovers() DeleteCookies(true) } else { Log("First run: Roblox window(s) visible, skipping initial cleanup.") DoNotify("Roblox active (window open), skipping cleanup.") } SetTimer WatchRoblox, 1000 DoNotify("Fk Roblox is watching") Log("Script started | Admin=" A_IsAdmin) WatchRoblox() { global RobloxExes, robloxRunning running := false for exe in RobloxExes { if ProcessExist(exe) { running := true break } } if (running && !robloxRunning) { robloxRunning := true Log("Roblox launched") DoNotify("Roblox started") return } if (!running && robloxRunning) { robloxRunning := false Log("Roblox closed") DoNotify("Roblox closed. Cleaning up...") KillLeftovers() Sleep 1000 DeleteCookies(true) } } AnyRobloxRunning() { global RobloxExes for exe in RobloxExes { if ProcessExist(exe) return true } return false } IsRobloxTrayOnly() { global RobloxExes visibleFound := false for exe in RobloxExes { pid := ProcessExist(exe) if pid { win := WinExist("ahk_pid " pid) if win && WinGetMinMax("ahk_pid " pid) != -1 visibleFound := true } } return (!visibleFound) } KillLeftovers() { global LeftoverExes for exe in LeftoverExes { while ProcessExist(exe) { ProcessClose exe Sleep 200 } Log("Ensured closed: " exe) } } DeleteCookies(allowElevate := true) { global CookieFile, AllowElevation if !FileExist(CookieFile) { Log("Cookie file not found") DoNotify("Cookie file not found.") return } try attrib := FileGetAttrib(CookieFile) catch attrib := "(attrib fetch error)" Log("Attempting deletion; attrib=" . attrib) try { FileSetAttrib("-R-S-H", CookieFile) Log("Attributes cleared before deletion") } catch { Log("FileSetAttrib failed on " . CookieFile) } Loop 5 { delException := "" try { FileDelete CookieFile Log("FileDelete attempted, A_LastError=" . A_LastError) } catch { delException := "FileDelete threw exception" Log("FileDelete exception caught | A_LastError=" . A_LastError) } Sleep 300 if !FileExist(CookieFile) { DoNotify("Cookies deleted.") Log("Cookie file deleted successfully") return } else { try attrib := FileGetAttrib(CookieFile) catch attrib := "(attrib fetch error)" Log("Delete failed; file still exists; attrib=" . attrib . " | A_LastError=" . A_LastError . (delException ? " | LastException=" . delException : "")) } try { tmp := CookieFile ".to_delete" FileMove CookieFile, tmp, 1 FileDelete tmp Log("Move+Delete workaround attempted (to " . tmp . ")") Sleep 200 if !FileExist(CookieFile) && !FileExist(tmp) { DoNotify("Cookies deleted (workaround).") Log("Cookie file deleted by move+delete workaround") return } } catch { Log("Move+Delete workaround failed | A_LastError=" . A_LastError) } try { Log("Attempting PowerShell Remove-Item fallback") RunWait('powershell -Command "Remove-Item -Path ' . '"' . CookieFile . '"' . ' -Force"',, 'Hide') Sleep 250 if !FileExist(CookieFile) { DoNotify("Cookies deleted (PowerShell).") Log("Cookie file deleted by PowerShell fallback") return } } catch { Log("PowerShell fallback failed | A_LastError=" . A_LastError) } } Log("Delete failed after all attempts | Admin=" . A_IsAdmin . " | File still exists: " . FileExist(CookieFile)) if (allowElevate && AllowElevation && !A_IsAdmin) { DoNotify("Elevation required – relaunching as Admin.") Log("Relaunching as admin with cleanup flag") Run('*RunAs "' . A_ScriptFullPath . '" --cleanup') ExitApp } Log("ERROR: Cookie file still exists after admin cleanup") } DoManualCleanup(*) { Log("Manual cleanup triggered.") DoNotify("Manual cleanup triggered!") KillLeftovers() Sleep 1000 DeleteCookies(true) } HasCleanupFlag() { for arg in A_Args { if (arg = "--cleanup") return true } return false } Log(msg) { global LogFile FileAppend("[" . A_Now . "] " . msg . "`n", LogFile) } DoNotify(msg, title := "Fk Roblox") { TrayTip(title, msg, 6) }