Steam VAC Repair Scripts for Windows & Linux

One script that fixes the most common VAC connection errors in Counter-Strike 2 and other VAC-secured games, then verifies CS2’s game files for you. No more digging through the Steam library. Pick your system below.

The error this fixes: Disconnected: You cannot play on secure servers for one of the following reasons: An issue with your computer is blocking the VAC system. You are unable to maintain a stable connection to the VAC system. You are running software that is modifying the game or is incompatible with VAC.

What usually causes it

According to Valve, this error happens when something interferes with Steam or the game. Common causes:

  • Software that modifies the game: skin changers, custom textures, DLL injectors and cheat tools.
  • Conflicting programs: Valve names CCleaner, PowerShell, Cheat Engine, IObit Start Menu, hypervisors (virtual machine software) and Steam idlers.
  • A broken Steam Service on Windows.
  • Changed Windows boot security settings (kernel integrity checks, debugging or DEP).
  • Corrupt game or system files, or a PC clock that’s out of sync.

What the Windows script does

StepWhat happens
1. Close CS2 and SteamShuts Steam down cleanly so it can be repaired.
2. Check for problem softwareLists any running programs from Valve’s conflict list and warns if a hypervisor is active. It only reports and doesn’t close anything.
3. Repair the Steam ServiceRuns Valve’s steamservice.exe /repair. The script finds your Steam folder automatically, even if Steam isn’t on drive C.
4. Sync the clockA wrong clock can break the connection to VAC.
5. Restore boot settingsValve’s four bcdedit commands. It warns you first if BitLocker is on.
6. Repair system files (optional)Runs DISM and SFC. Takes 15–30 minutes, and the script asks before running it.
7. Verify CS2Opens Steam and starts Verify integrity of game files for CS2 automatically.

How to use it

  1. Click Copy script below, or select all of the script text and copy it.
  2. Open Notepad and paste.
  3. Click File → Save As. Set Save as type to All Files and name it Steam-VAC-Repair.bat. Save it to your Desktop.
  4. Double-click the file. Click Yes when Windows asks for administrator permission.
  5. Follow the prompts. Press Y for yes and N for no.
  6. When Steam finishes verifying CS2, restart your PC.

BitLocker users: step 5 changes boot settings, which can make Windows ask for your BitLocker recovery key on the next restart. Have your key ready from account.microsoft.com/devices/recoverykey, or answer N to skip that step.

If Windows SmartScreen says “Windows protected your PC”, click More info, then Run anyway. That happens with any script you make yourself.

Steam-VAC-Repair.bat
@echo off
setlocal EnableExtensions
:: ============================================================================
::  Steam / VAC Repair Script for Windows 10 and 11
::  Fixes "You cannot play on secure servers" / VAC errors in CS2 and other
::  VAC-secured games, then verifies CS2's game files automatically.
::
::  Based on Valve's official steps:
::  https://help.steampowered.com/en/faqs/view/22C0-03D0-AE4B-04E8
::
::  Use at your own risk. When in doubt, follow Valve's directions instead.
::  Loren Tedford | https://LorenTedford.com
:: ============================================================================

title Steam VAC Repair Script - Loren Tedford ^| LorenTedford.com

:: ---------------------------------------------------------------------------
:: Run as administrator (asks Windows for permission if needed)
:: ---------------------------------------------------------------------------
net session >nul 2>&1
if errorlevel 1 (
    echo Asking Windows for administrator permission...
    powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
    exit /b
)

:: CS2's Steam app ID. Change this to repair a different game (e.g. 440 = TF2).
set "APPID=730"

:: ---------------------------------------------------------------------------
:: Find Steam
:: ---------------------------------------------------------------------------
set "STEAM="
for /f "tokens=2,*" %%A in ('reg query "HKLM\SOFTWARE\WOW6432Node\Valve\Steam" /v InstallPath 2^>nul ^| find /i "InstallPath"') do set "STEAM=%%B"
if not defined STEAM for /f "tokens=2,*" %%A in ('reg query "HKCU\Software\Valve\Steam" /v SteamPath 2^>nul ^| find /i "SteamPath"') do set "STEAM=%%B"
if not defined STEAM set "STEAM=C:\Program Files (x86)\Steam"
set "STEAM=%STEAM:/=\%"

if not exist "%STEAM%\steam.exe" (
    echo.
    echo  Could not find Steam. Looked in: "%STEAM%"
    echo  Edit this script and set the STEAM line to your Steam folder.
    echo.
    pause
    exit /b 1
)

cls
echo ============================================================
echo   Steam VAC Repair Script for Windows
echo   Loren Tedford ^| https://LorenTedford.com
echo ============================================================
echo.
echo   Steam folder: %STEAM%
echo.
echo   This script will:
echo     1. Close CS2 and Steam
echo     2. Check for software Valve says can cause VAC errors
echo     3. Repair the Steam Service
echo     4. Sync your PC clock
echo     5. Restore Windows boot security settings to default
echo     6. (Optional) Repair Windows system files
echo     7. Start Steam and verify CS2's game files
echo.
echo   Save your work in other programs first.
echo.
choice /c YN /m "  Start the repair"
if errorlevel 2 exit /b 0

:: ---------------------------------------------------------------------------
:: 1. Close CS2 and Steam
:: ---------------------------------------------------------------------------
echo.
echo [1/7] Closing CS2 and Steam...
taskkill /im cs2.exe /f >nul 2>&1
tasklist /fi "imagename eq steam.exe" 2>nul | find /i "steam.exe" >nul
if not errorlevel 1 (
    start "" "%STEAM%\steam.exe" -shutdown
    echo       Waiting for Steam to close...
    timeout /t 10 /nobreak >nul
)
taskkill /im steam.exe /f >nul 2>&1
taskkill /im steamwebhelper.exe /f >nul 2>&1
echo       Done.

:: ---------------------------------------------------------------------------
:: 2. Check for software Valve lists as causing VAC errors (report only)
:: ---------------------------------------------------------------------------
echo.
echo [2/7] Checking for software that can cause VAC errors...
set "FOUND="
for %%P in (ccleaner.exe ccleaner64.exe cheatengine-x86_64.exe cheatengine-i386.exe cheatengine.exe StartMenu8.exe pwsh.exe VirtualBox.exe VBoxHeadless.exe vmware.exe vmware-vmx.exe ArchiSteamFarm.exe "Idle Master.exe" SteamIdler.exe) do (
    tasklist /fi "imagename eq %%~P" 2>nul | find /i "%%~P" >nul && (
        echo       FOUND RUNNING: %%~P
        set "FOUND=1"
    )
)
tasklist /fi "imagename eq powershell.exe" 2>nul | find /i "powershell.exe" >nul && (
    echo       FOUND RUNNING: powershell.exe  ^(close any open PowerShell windows^)
    set "FOUND=1"
)
if defined FOUND (
    echo.
    echo       Close the programs above before playing. Valve lists them as
    echo       common causes of this error.
) else (
    echo       None found.
)
systeminfo 2>nul | find /i "A hypervisor has been detected" >nul && (
    echo.
    echo       NOTE: A hypervisor is running ^(Hyper-V, WSL2, Windows Sandbox,
    echo       Memory Integrity / VBS, or other virtual machine software^).
    echo       Valve lists hypervisors as a possible cause. If VAC errors
    echo       continue after this script, see the directions page.
)

:: ---------------------------------------------------------------------------
:: 3. Repair the Steam Service
:: ---------------------------------------------------------------------------
echo.
echo [3/7] Repairing the Steam Service (may take a few minutes)...
if exist "%STEAM%\bin\steamservice.exe" (
    "%STEAM%\bin\steamservice.exe" /repair
    echo       Done.
) else (
    echo       steamservice.exe not found in "%STEAM%\bin". Skipping.
)

:: ---------------------------------------------------------------------------
:: 4. Sync the PC clock (a wrong clock can break the VAC connection)
:: ---------------------------------------------------------------------------
echo.
echo [4/7] Syncing your PC clock...
sc query w32time | find /i "RUNNING" >nul || net start w32time >nul 2>&1
w32tm /resync >nul 2>&1
if errorlevel 1 (
    echo       Could not sync automatically. Open Settings, Time ^& language,
    echo       Date ^& time, and click "Sync now".
) else (
    echo       Clock synced.
)

:: ---------------------------------------------------------------------------
:: 5. Restore boot security settings to default (Valve's bcdedit steps)
:: ---------------------------------------------------------------------------
echo.
echo [5/7] Restoring Windows boot security settings to default...
manage-bde -status %SystemDrive% 2>nul | find /i "Protection On" >nul
if not errorlevel 1 (
    echo.
    echo       BitLocker is ON for %SystemDrive%. Changing boot settings can make
    echo       Windows ask for your BitLocker recovery key on the next restart.
    echo       Make sure you have your recovery key before continuing
    echo       ^(https://account.microsoft.com/devices/recoverykey^).
    echo.
    choice /c YN /m "      Continue with the boot settings step"
    if errorlevel 2 goto :skipboot
)
bcdedit /deletevalue nointegritychecks >nul 2>&1
bcdedit /deletevalue loadoptions >nul 2>&1
bcdedit /debug off >nul 2>&1
bcdedit /deletevalue nx >nul 2>&1
echo       Done. Kernel integrity checks, kernel debugging and DEP are at default.
echo       ^(If Secure Boot is on, these are already locked to default.^)
set "NEEDREBOOT=1"
goto :sysfiles
:skipboot
echo       Skipped.

:: ---------------------------------------------------------------------------
:: 6. Optional: repair Windows system files
:: ---------------------------------------------------------------------------
:sysfiles
echo.
echo [6/7] Repair Windows system files?
echo       This runs DISM and SFC. It can take 15-30 minutes.
echo       Recommended if VAC errors keep coming back.
choice /c YN /m "      Run system file repair now"
if errorlevel 2 (
    echo       Skipped.
    goto :validate
)
echo       Running DISM (repairs the Windows component store)...
DISM /Online /Cleanup-Image /RestoreHealth
echo.
echo       Running SFC (repairs Windows system files)...
sfc /scannow
set "NEEDREBOOT=1"

:: ---------------------------------------------------------------------------
:: 7. Start Steam and verify CS2's game files
:: ---------------------------------------------------------------------------
:validate
echo.
echo [7/7] Starting Steam and verifying CS2 game files...
start "" "steam://validate/%APPID%"
echo       Steam will open and check CS2's files. Watch the Downloads page
echo       in Steam until it finishes.

echo.
echo ============================================================
echo   Repair finished.
if defined NEEDREBOOT (
    echo.
    echo   IMPORTANT: RESTART YOUR PC once Steam finishes verifying
    echo   CS2. The boot and system file changes need a restart.
)
echo.
echo   If the error comes back:
echo     - Remove skin changers, custom textures and overlays/injectors
echo     - Close the programs listed in step 2
echo     - See the directions page for more help
echo.
echo   Loren Tedford ^| https://LorenTedford.com
echo ============================================================
echo.
pause
endlocal
exit /b 0

Still getting the error?

  • Restart the PC if you haven’t since running the script. The boot changes only take effect after a restart.
  • Remove skin changers, custom textures, overlays that inject into the game, and anything that changes CS2’s files. Then run the script again so it re-verifies the game.
  • Hypervisors: if step 2 said a hypervisor is running, close virtual machines first (VirtualBox, VMware, WSL, Windows Sandbox). If the error continues, Valve lists hypervisors as a cause. Turning off Hyper-V, or Memory Integrity under Windows Security → Device security → Core isolation, may help, but it lowers a Windows security protection. Only do it if nothing else works, and turn it back on if it doesn’t help.
  • Prefer to do it by hand? Follow Valve’s official steps: Disconnected by VAC: You cannot play on secure servers.

What the Linux script does

CS2 runs natively on Linux, so Windows-only steps like the Steam Service and boot settings don’t apply. The Linux script focuses on what does.

StepWhat happens
1. Close CS2 and SteamShuts Steam down cleanly. It works with the regular Steam package, the Flatpak version and the Snap version.
2. Check for problem softwareLooks for cheat or memory tools and idlers. It also warns if LD_PRELOAD is set in your session or in a game’s launch options, since that loads extra code into games.
3. Check the clockConfirms automatic time sync is on, and offers to turn it on if it isn’t.
4. Reset Steam’s app cache (optional)Renames the cache folder to a backup. Nothing is deleted, and Steam rebuilds it.
5. Verify CS2Opens Steam and starts Verify integrity of game files for CS2 automatically.

How to use it

  1. Click Copy script below, or select all of the script text and copy it.
  2. Open a text editor (Text Editor, Kate, gedit or nano), paste, and save it in your home folder as steam-vac-repair-linux.sh.
  3. Open a terminal and make it runnable:
    chmod +x ~/steam-vac-repair-linux.sh
  4. Run it as your normal user, not with sudo:
    ~/steam-vac-repair-linux.sh
  5. Follow the prompts and type y or n. It only asks for your password if your clock needs fixing.

Some desktops can also run it by right-clicking the file and choosing Run as a Program. If you do that, make sure it opens in a terminal so you can answer the prompts.

steam-vac-repair-linux.sh
#!/usr/bin/env bash
# ============================================================================
#  Steam / VAC Repair Script for Linux
#  Fixes "You cannot play on secure servers" / VAC errors in CS2 and other
#  VAC-secured games, then verifies CS2's game files automatically.
#
#  Works with the native Steam package and the Flatpak version of Steam.
#  Run it as your normal user, NOT with sudo. It asks for sudo itself only
#  if your clock needs fixing.
#
#  Usage:   chmod +x steam-vac-repair-linux.sh
#           ./steam-vac-repair-linux.sh
#
#  Use at your own risk. When in doubt, follow Valve's directions instead.
#  Loren Tedford | https://LorenTedford.com
# ============================================================================

set -u

# CS2's Steam app ID. Change this to repair a different game (e.g. 440 = TF2).
APPID=730

bold=$(tput bold 2>/dev/null || true)
reset=$(tput sgr0 2>/dev/null || true)

step()  { printf '\n%s[%s] %s%s\n' "$bold" "$1" "$2" "$reset"; }
info()  { printf '      %s\n' "$*"; }
ask()   {  # ask "Question" -> returns 0 for yes, 1 for no
    local reply
    while true; do
        read -r -p "      $1 [y/n]: " reply || return 1   # no input = no
        case "${reply,,}" in
            y|yes) return 0 ;;
            n|no)  return 1 ;;
        esac
    done
}

if [ "$(id -u)" -eq 0 ]; then
    echo "Please run this script as your normal user, not with sudo or as root."
    echo "Steam is installed per user, so running as root would repair the wrong account."
    exit 1
fi

# ---------------------------------------------------------------------------
# Detect how Steam is installed
# ---------------------------------------------------------------------------
STEAM_KIND=""
if command -v flatpak >/dev/null 2>&1 && flatpak info com.valvesoftware.Steam >/dev/null 2>&1; then
    STEAM_KIND="flatpak"
fi
if command -v steam >/dev/null 2>&1; then
    # Prefer native if both are present and the native data folder exists
    if [ -z "$STEAM_KIND" ] || [ -d "$HOME/.local/share/Steam" ] || [ -d "$HOME/.steam/steam" ]; then
        STEAM_KIND="native"
    fi
fi
if [ -z "$STEAM_KIND" ] && command -v snap >/dev/null 2>&1 && snap list steam >/dev/null 2>&1; then
    STEAM_KIND="snap"
fi

if [ -z "$STEAM_KIND" ]; then
    echo "Could not find Steam (checked native, Flatpak and Snap)."
    exit 1
fi

steam_cmd() {
    case "$STEAM_KIND" in
        native)  steam "$@" ;;
        flatpak) flatpak run com.valvesoftware.Steam "$@" ;;
        snap)    snap run steam "$@" ;;
    esac
}

# Find the Steam data folder
STEAM_DIR=""
for d in \
    "$HOME/.var/app/com.valvesoftware.Steam/.local/share/Steam" \
    "$HOME/snap/steam/common/.local/share/Steam" \
    "$HOME/.local/share/Steam" \
    "$HOME/.steam/steam" \
    "$HOME/.steam/debian-installation"; do
    if [ -d "$d/steamapps" ] || [ -d "$d/userdata" ]; then
        case "$STEAM_KIND:$d" in
            flatpak:*/.var/app/*|snap:*/snap/steam/*|native:"$HOME"/.local/*|native:"$HOME"/.steam/*)
                STEAM_DIR="$d"; break ;;
        esac
    fi
done

clear 2>/dev/null || true
echo "============================================================"
echo "  Steam VAC Repair Script for Linux"
echo "  Loren Tedford | https://LorenTedford.com"
echo "============================================================"
echo
echo "  Steam type:   $STEAM_KIND"
echo "  Steam folder: ${STEAM_DIR:-not found (some checks will be skipped)}"
echo
echo "  This script will:"
echo "    1. Close CS2 and Steam"
echo "    2. Check for software that can cause VAC errors"
echo "    3. Check that your clock is synced"
echo "    4. (Optional) Reset Steam's app cache"
echo "    5. Start Steam and verify CS2's game files"
echo
if ! ask "Start the repair?"; then
    exit 0
fi

# ---------------------------------------------------------------------------
# 1. Close CS2 and Steam
# ---------------------------------------------------------------------------
step "1/5" "Closing CS2 and Steam..."
pkill -x cs2 2>/dev/null || true
if pgrep -x steam >/dev/null 2>&1 || pgrep -f 'steamwebhelper' >/dev/null 2>&1; then
    steam_cmd -shutdown >/dev/null 2>&1 &
    info "Waiting for Steam to close..."
    for _ in $(seq 1 30); do
        pgrep -x steam >/dev/null 2>&1 || break
        sleep 1
    done
    if pgrep -x steam >/dev/null 2>&1; then
        info "Steam didn't close on its own. Stopping it."
        pkill -x steam 2>/dev/null || true
        sleep 2
    fi
fi
pkill -f steamwebhelper 2>/dev/null || true
info "Done."

# ---------------------------------------------------------------------------
# 2. Check for software that can cause VAC errors (report only)
# ---------------------------------------------------------------------------
step "2/5" "Checking for software that can cause VAC errors..."
FOUND=0
for p in cheatengine scanmem GameConqueror ArchiSteamFarm steam-idle idle_master; do
    if pgrep -if "$p" >/dev/null 2>&1; then
        info "FOUND RUNNING: $p"
        FOUND=1
    fi
done
[ "$FOUND" -eq 0 ] && info "No known problem programs running."

# Programs injected into the game through launch options (LD_PRELOAD etc.)
if [ -n "$STEAM_DIR" ] && [ -d "$STEAM_DIR/userdata" ]; then
    hits=$(grep -il 'LD_PRELOAD' "$STEAM_DIR"/userdata/*/config/localconfig.vdf 2>/dev/null || true)
    if [ -n "$hits" ]; then
        info ""
        info "WARNING: A game's launch options use LD_PRELOAD. Programs injected"
        info "this way can be flagged as incompatible with VAC. In Steam, right-"
        info "click CS2 > Properties > General and check LAUNCH OPTIONS. Remove"
        info "anything that loads extra libraries into the game."
    fi
fi
if [ -n "${LD_PRELOAD:-}" ]; then
    info ""
    info "WARNING: LD_PRELOAD is set in your session: $LD_PRELOAD"
    info "Anything in it is loaded into every game. Remove it before playing."
fi

# ---------------------------------------------------------------------------
# 3. Check the clock (a wrong clock can break the VAC connection)
# ---------------------------------------------------------------------------
step "3/5" "Checking that your clock is synced..."
if command -v timedatectl >/dev/null 2>&1; then
    synced=$(timedatectl show -p NTPSynchronized --value 2>/dev/null || echo "unknown")
    ntp_on=$(timedatectl show -p NTP --value 2>/dev/null || echo "unknown")
    if [ "$synced" = "yes" ]; then
        info "Clock is synced."
    else
        info "Clock is NOT confirmed synced (NTP service: $ntp_on)."
        if ask "Turn on automatic time sync now? (uses sudo)"; then
            if sudo timedatectl set-ntp true; then
                info "Automatic time sync turned on. It may take a minute to sync."
            else
                info "Could not turn on time sync. Check your desktop's Date & Time settings."
            fi
        fi
    fi
else
    info "timedatectl not available. Check your Date & Time settings are set to automatic."
fi

# ---------------------------------------------------------------------------
# 4. Optional: reset Steam's app cache (it's rebuilt automatically)
# ---------------------------------------------------------------------------
step "4/5" "Reset Steam's app cache?"
info "This clears Steam's cached game info. Nothing is deleted; the old"
info "folder is renamed to a backup, and Steam rebuilds it when it starts."
if [ -n "$STEAM_DIR" ] && [ -d "$STEAM_DIR/appcache" ]; then
    if ask "Reset the app cache?"; then
        backup="$STEAM_DIR/appcache.bak-$(date +%Y%m%d-%H%M%S)"
        if mv "$STEAM_DIR/appcache" "$backup"; then
            info "Moved to: $backup"
            info "You can delete that backup once everything works."
        else
            info "Could not rename the app cache. Skipping."
        fi
    else
        info "Skipped."
    fi
else
    info "App cache folder not found. Skipping."
fi

# ---------------------------------------------------------------------------
# 5. Start Steam and verify CS2's game files
# ---------------------------------------------------------------------------
step "5/5" "Starting Steam and verifying CS2 game files..."
nohup bash -c "$(declare -f steam_cmd); STEAM_KIND='$STEAM_KIND'; steam_cmd 'steam://validate/$APPID'" >/dev/null 2>&1 &
disown 2>/dev/null || true
info "Steam will open and check CS2's files. Watch the Downloads page"
info "in Steam until it finishes."

echo
echo "============================================================"
echo "  Repair finished."
echo
echo "  If the error comes back:"
echo "    - Run CS2 natively. In Steam: right-click CS2 > Properties >"
echo "      Compatibility, and make sure Proton is NOT forced."
echo "    - Remove skin changers, custom textures and anything in"
echo "      CS2's launch options that injects into the game"
echo "    - Restart your PC, then try again"
echo "    - See the directions page for more help"
echo
echo "  Loren Tedford | https://LorenTedford.com"
echo "============================================================"

Still getting the error?

  • Don’t force Proton on CS2. CS2 has a native Linux version. In Steam, right-click CS2 → Properties → Compatibility and make sure Force the use of a specific Steam Play compatibility tool is unchecked.
  • Check the launch options. Right-click CS2 → Properties → General → Launch Options. Remove anything that injects into the game. If you use an overlay like MangoHud and get VAC errors, try without it.
  • Restart your PC, then launch Steam and try again.
  • Still stuck? Post in the CS2 Steam discussions with your distro and Steam type.

Quick tip: verify any game without opening the library

Both scripts use this Steam link, which starts Verify integrity of game files directly. On Windows, press Win + R, paste it and press Enter. On Linux, run it with steam or xdg-open:

steam://validate/730

730 is CS2’s app ID. Use a different number for another game. You’ll find it in the game’s Steam store page address, for example store.steampowered.com/app/730/.

Disclaimer

Use at your own risk. These scripts and directions are provided for general information only, “as is”, with no warranty of any kind. They change Steam, Windows boot and system settings, which can cause problems such as a BitLocker recovery prompt. You are responsible for any changes you make to your own system. The author is not liable for any damage, data loss, lost game access or other problems that result from using them. When in doubt, follow Valve’s official directions instead.

No guarantee. These scripts can fix connection and setup problems that block VAC. They cannot remove or appeal a VAC ban, and they won’t help if cheat or modding software is still installed.

Read before you run. Never run a script you don’t understand. Both scripts are plain text, so you can read every step before running them.

Not affiliated. This page is independent and is not affiliated with, endorsed by or sponsored by Valve or Microsoft. Steam, Counter-Strike 2 and VAC are trademarks of Valve Corporation. Windows and BitLocker are trademarks of Microsoft. Linux is a trademark of Linus Torvalds.

Loren Tedford | https://LorenTedford.com