Skip to content

Instantly share code, notes, and snippets.

@AndrewMast
Last active May 2, 2024 03:44
Show Gist options
  • Star 67 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save AndrewMast/742ac7e07c37096017e907b0fd8ec7bb to your computer and use it in GitHub Desktop.
Save AndrewMast/742ac7e07c37096017e907b0fd8ec7bb to your computer and use it in GitHub Desktop.
Commands to disable Riot Vanguard when you aren't playing Valorant

Commands to temporarily stop Riot Vanguard

As oddly as it sounds, people actually do other things on their computer than play Valorant. I've put together a few commands to turn off Riot Vanguard for when you aren't playing Valorant.

Proof that I'm not hacking your computer

On Riot's support website for Valorant, they list two commands in the third step in the process of manually uninstalling Riot Vanguard. Link to the page. These commands are sc delete vgc and sc delete vgk. These commands are telling Windows Services (known to the command line as sc) to delete two services (vgc and vgk). My commands simply disable these services from starting next time you start your computer by changing their configuration to disabled (ie. sc config vgc start= disabled)

Commands for people who don't know how commands work

If you don't know how commands work or you just want the easiest way to disable and enable Vanguard, I have created a few files for the best experience:

How to get these files:

Click here to download all of the files (same as hitting "Download ZIP" at the top right-ish of the page)

OR

  1. Click on one of the links above to scroll down to the file
  2. Right click on the "Raw" button for the file
  3. Select "Save Link As..." or "Download File As..."
  4. Before saving, make sure to set the "Save as type" field to All Files (*.*) to ensure that the file is saved with the extension .vbs (very important)

How these files work:

These files run the same commands provided below, but asks you to run the command as administrator first. Let's dissect the code, eh? Take disable_vanguard.vbs for example:

Call CreateObject("Shell.Application").ShellExecute("cmd.exe", "/c ""sc config vgc start= disabled & sc config vgk start= disabled""", "", "runas")

If you noticed, in the middle of this code you can see sc config vgc start= disabled & sc config vgk start= disabled which is the exact command that I provide for the more "experienced" people (see below). The Call CreateObject("Shell.Application").ShellExecute part of the code gets ready to launch command prompt. Then cmd.exe is given to this so it can be opened, and /c ""{...}"" simply tells command prompt what command to run (I left out the command on purpose). Finally, runas tells the code that it needs to ask you for permission to run the command as an administrator.

The restart command

If you choose to use the command to restart your computer, shutdown /r /f /t 00 is included in the command. shutdown tells command prompt that you want to shutdown your computer, but /r tells it to restart. /f tells it to close all open programs and /t 00 tells it to shutdown right away.

The close command

If you choose to use the command to stop Vanguard, net stop vgc & net stop vgk & taskkill /IM vgtray.exe is included in the command. net stop vgc and net stop vgk tells command prompt to stop the Vanguard services (see above for proof that these are actually Vanguard's services) and taskkill /IM vgtray.exe tells command prompt to close the Vanguard tray icon (otherwise it would stay open even after you stop the services)

Commands for experienced cmders

If you know how to open an elevated command prompt (super easy, barely an inconvenience: search for cmd in the start menu, right click it, run as admin), then you can just run these commands to disable or enable Riot Vanguard (still requires a reboot once you enable it)

# Disable Vanguard (in disable_vanguard.vbs)
sc config vgc start= disabled & sc config vgk start= disabled

# Disable and stop Vanguard (in disable_vanguard_stop.vbs)
sc config vgc start= disabled & sc config vgk start= disabled & net stop vgc & net stop vgk & taskkill /IM vgtray.exe

# Enable Vanguard (in enable_vanguard.vbs)
sc config vgc start= demand & sc config vgk start= system

# Enable Vanguard and restart your computer (in enable_vanguard_restart.vbs)
sc config vgc start= demand & sc config vgk start= system & shutdown /r /f /t 00
' Disables Vanguard from starting when you boot your computer
Call CreateObject("Shell.Application").ShellExecute("cmd.exe", "/c ""sc config vgc start= disabled & sc config vgk start= disabled""", "", "runas")
' Disables Vanguard from starting when you boot your computer and also stops Vanguard
Call CreateObject("Shell.Application").ShellExecute("cmd.exe", "/c ""sc config vgc start= disabled & sc config vgk start= disabled & net stop vgc & net stop vgk & taskkill /IM vgtray.exe""", "", "runas")
' Enables Vanguard so it starts next time you boot your computer
Call CreateObject("Shell.Application").ShellExecute("cmd.exe", "/c ""sc config vgc start= demand & sc config vgk start= system""", "", "runas")
' Enables Vanguard and then reboots your computer to Vanguard
Call CreateObject("Shell.Application").ShellExecute("cmd.exe", "/c ""sc config vgc start= demand & sc config vgk start= system & shutdown /r /f /t 00""", "", "runas")
@dr4k0nia
Copy link

Thanks a lot for your guide Andrew!

I took inspiration from your guide and made a all in one batch script that might be useful for some people. I decided to write this script to overcome some "issues" I personally had. I did not like the need for multiple scripts and also have VBS disabled by default which was my main issue 😄

The script does almost everything in one run

  • Check if vgc and vgk are set to start automatically
    • Disable and stop them if they are
    • Enable auto starting if its disabled
  • Kill vgtray.exe if it is running

I removed the restart since I personally dont need it, but it can easily be added.

@echo off

@REM Checks if vgc is auto starting
@REM If it is we disable the auto start and attempt to stop the service
for /F "tokens=3 delims=: " %%H in ('sc qc "vgc" ^| findstr /i "START_TYPE"') do (
  if /I "%%H" EQU "DEMAND_START" (
   sc config vgc start= disabled
   echo Disabled vgc AutoStart
   call :CheckServiceState vgc
  ) else (
    sc config vgc start= demand
    echo Enabled vgc auto starting
  )
)

@REM Check if vgk AutoStart is enabled
@REM If it is we disable the auto start and attempt to stop the service
for /F "tokens=3 delims=: " %%H in ('sc qc "vgk" ^| findstr /i "START_TYPE"') do (
  if /I "%%H" EQU "SYSTEM_START" (
   sc config vgk start= disabled
   echo Disabled vgk AutoStart
   call :CheckServiceState vgk
  ) else (
    sc config vgk start= system
    echo Enabled vgk auto starting
  )
)

@REM Kill vgtray.exe if it is running else print an empty line
tasklist | find /i "vgtray.exe" && taskkill /im vgtray.exe /F || echo(

pause


@REM Check if a service with the supplied name is running and stop it in case it is running
:CheckServiceState
for /F "tokens=3 delims=: " %%H in ('sc query "%~1" ^| findstr /i "STATE"') do (
  if /I "%%H" EQU "RUNNING" (
   net stop %~1
   echo Stopped Service %~1
  )
)
exit /B

@qualk
Copy link

qualk commented Feb 24, 2023

Thanks a lot for your guide Andrew!

I took inspiration from your guide and made a all in one batch script that might be useful for some people. I decided to write this script to overcome some "issues" I personally had. I did not like the need for multiple scripts and also have VBS disabled by default which was my main issue 😄

The script does almost everything in one run

  • Check if vgc and vgk are set to start automatically

    • Disable and stop them if they are
    • Enable auto starting if its disabled
  • Kill vgtray.exe if it is running

I removed the restart since I personally dont need it, but it can easily be added.

@echo off

@REM Checks if vgc is auto starting
@REM If it is we disable the auto start and attempt to stop the service
for /F "tokens=3 delims=: " %%H in ('sc qc "vgc" ^| findstr /i "START_TYPE"') do (
  if /I "%%H" EQU "DEMAND_START" (
   sc config vgc start= disabled
   echo Disabled vgc AutoStart
   call :CheckServiceState vgc
  ) else (
    sc config vgc start= demand
    echo Enabled vgc auto starting
  )
)

@REM Check if vgk AutoStart is enabled
@REM If it is we disable the auto start and attempt to stop the service
for /F "tokens=3 delims=: " %%H in ('sc qc "vgk" ^| findstr /i "START_TYPE"') do (
  if /I "%%H" EQU "SYSTEM_START" (
   sc config vgk start= disabled
   echo Disabled vgk AutoStart
   call :CheckServiceState vgk
  ) else (
    sc config vgk start= system
    echo Enabled vgk auto starting
  )
)

@REM Kill vgtray.exe if it is running else print an empty line
tasklist | find /i "vgtray.exe" && taskkill /im vgtray.exe /F || echo(

pause


@REM Check if a service with the supplied name is running and stop it in case it is running
:CheckServiceState
for /F "tokens=3 delims=: " %%H in ('sc query "%~1" ^| findstr /i "STATE"') do (
  if /I "%%H" EQU "RUNNING" (
   net stop %~1
   echo Stopped Service %~1
  )
)
exit /B

gah damn, thank you so much for the script, and thank you OP for the original commands!

@hatred-dev
Copy link

hatred-dev commented Jun 12, 2023

Thanks for the reference. And to the guy who took the inspiration.

Thanks a lot for your guide Andrew!

I took inspiration from your guide and made a all in one batch script that might be useful for some people. I decided to write this script to overcome some "issues" I personally had. I did not like the need for multiple scripts and also have VBS disabled by default which was my main issue 😄

The script does almost everything in one run

* Check if vgc and vgk are set to start automatically
  
  * Disable and stop them if they are
  * Enable auto starting if its disabled

* Kill vgtray.exe if it is running

Script does the same but with automatic privilege escalation and restart prompt. Requires powershell tho.

$currentScriptPath = $MyInvocation.MyCommand.Definition
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
$needsRestart = $false

if (-not $isAdmin) {
    Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$currentScriptPath`"" -Verb RunAs
    exit
}

try {
    $service = Get-Service -Name "vgc"
    if ($service.StartType -eq "Manual") {
        $service | Set-Service -StartupType "Disabled"
        Stop-Service $service -ErrorAction SilentlyContinue
        Write-Host "VGC disabled"
    }
    else {
        $service | Set-Service -StartupType "Manual"
        Write-Host "VGC enabled"
    }

    $service = Get-Service -Name "vgk"
    if ($service.StartType -eq "System") {
        $service | Set-Service -StartupType "Disabled"
        Stop-Service $service -ErrorAction SilentlyContinue
        Write-Output "VGK disabled"
    }
    else {
        $command = { sc.exe config vgk start= system }
        . $command | Out-Null
        $needsRestart = $true
        Write-Host "VGK enabled"
    }
}
catch {
    Write-Host $_
}

Get-Process -Name "vgtray" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue

if ($needsRestart) {
    Write-Host "To load driver, restart is required."
    Restart-Computer -Confirm
}

Write-Host "Press any key to continue..." -NoNewline
[void][System.Console]::ReadKey($true)

@BanCrash
Copy link

Hi, since I'm on W10 and I don't have TPM 2.0, since july 6 I wouldn't be able to play Valorant unless I disable one security component of Windows (VBS). Could the script be update to add an option to enable and disable this component while enabling or disabling vanguard? Or pointing me out to do by myself, I don't know where to start tbh.

So when enabling vanguard, VBS will be disabled, and when Vanguard is disabled, VBS will be enabled.

https://support-valorant.riotgames.com/hc/en/articles/16941220890899

@hatred-dev
Copy link

So when enabling vanguard, VBS will be disabled, and when Vanguard is disabled, VBS will be enabled.

You're talking about core isolation?

@BanCrash
Copy link

BanCrash commented Jul 2, 2023

So when enabling vanguard, VBS will be disabled, and when Vanguard is disabled, VBS will be enabled.

You're talking about core isolation?

No, I was talking about Virtualization based security, which can be disabled and enabled with powershell with this command:
bcdedit /set hypervisorlaunchtype off for disabling and bcdedit /set hypervisorlaunchtype auto for enabling.

I did a few tests and It was as simple as adding those commands after disabling or enabling VGK, and also forcing restart everytime.

This is the code I used but as I said is just your already done code with that additions:

$currentScriptPath = $MyInvocation.MyCommand.Definition
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
$needsRestart = $true

if (-not $isAdmin) {
    Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$currentScriptPath`"" -Verb RunAs
    exit
}

try {
    $service = Get-Service -Name "vgc"
    if ($service.StartType -eq "Manual") {
        $service | Set-Service -StartupType "Disabled"
        Stop-Service $service -ErrorAction SilentlyContinue
        Write-Host "VGC disabled"
    }
    else {
        $service | Set-Service -StartupType "Manual"
        Write-Host "VGC enabled"
    }

    $service = Get-Service -Name "vgk"
    if ($service.StartType -eq "System") {
        $service | Set-Service -StartupType "Disabled"
        Stop-Service $service -ErrorAction SilentlyContinue
        Write-Output "VGK disabled"
        bcdedit /set hypervisorlaunchtype auto
    }
    else {
        $command = { sc.exe config vgk start= system }
        . $command | Out-Null
        Write-Host "VGK enabled"
        bcdedit /set hypervisorlaunchtype off
    }
}
catch {
    Write-Host $_
}

Get-Process -Name "vgtray" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue

if ($needsRestart) {
    Write-Host "To load driver, restart is required."
    Restart-Computer -Confirm
}

Write-Host "Press any key to continue..." -NoNewline
[void][System.Console]::ReadKey($true)

@hatred-dev
Copy link

Quite handy isn't it

@Sehnyu
Copy link

Sehnyu commented Jan 23, 2024

Thanks a lot for your guide Andrew!

I took inspiration from your guide and made a all in one batch script that might be useful for some people. I decided to write this script to overcome some "issues" I personally had. I did not like the need for multiple scripts and also have VBS disabled by default which was my main issue 😄

The script does almost everything in one run

* Check if vgc and vgk are set to start automatically
  
  * Disable and stop them if they are
  * Enable auto starting if its disabled

* Kill vgtray.exe if it is running

I removed the restart since I personally dont need it, but it can easily be added.

@echo off

@REM Checks if vgc is auto starting
@REM If it is we disable the auto start and attempt to stop the service
for /F "tokens=3 delims=: " %%H in ('sc qc "vgc" ^| findstr /i "START_TYPE"') do (
  if /I "%%H" EQU "DEMAND_START" (
   sc config vgc start= disabled
   echo Disabled vgc AutoStart
   call :CheckServiceState vgc
  ) else (
    sc config vgc start= demand
    echo Enabled vgc auto starting
  )
)

@REM Check if vgk AutoStart is enabled
@REM If it is we disable the auto start and attempt to stop the service
for /F "tokens=3 delims=: " %%H in ('sc qc "vgk" ^| findstr /i "START_TYPE"') do (
  if /I "%%H" EQU "SYSTEM_START" (
   sc config vgk start= disabled
   echo Disabled vgk AutoStart
   call :CheckServiceState vgk
  ) else (
    sc config vgk start= system
    echo Enabled vgk auto starting
  )
)

@REM Kill vgtray.exe if it is running else print an empty line
tasklist | find /i "vgtray.exe" && taskkill /im vgtray.exe /F || echo(

pause


@REM Check if a service with the supplied name is running and stop it in case it is running
:CheckServiceState
for /F "tokens=3 delims=: " %%H in ('sc query "%~1" ^| findstr /i "STATE"') do (
  if /I "%%H" EQU "RUNNING" (
   net stop %~1
   echo Stopped Service %~1
  )
)
exit /B

This is a .bat file right?
I'm not sure why, but whenever I run this file, Vanguard closes, independent of if its enables or disables the auto-start. But on restart it always restarts, regardless of if I ran the code or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment