Skip to content

Instantly share code, notes, and snippets.

@espresso3389
Last active September 16, 2019 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save espresso3389/f5d2d0f99d9a42d38407c44bb8e407cc to your computer and use it in GitHub Desktop.
Save espresso3389/f5d2d0f99d9a42d38407c44bb8e407cc to your computer and use it in GitHub Desktop.
Script to configure VSCode not to use GPU acceleration
@echo off
setlocal enabledelayedexpansion
rem Additional options to append to VSCode launching command lines.
set ADDTIONAL_OPTS=--disable-gpu
rem insiders, exploration, or other for normal version.
set FLAVOR=insiders
rem VSCode, VSCode Insiders, VSCode Exploration,...
if %FLAVOR%==insiders (
set VSCode=VSCodeInsiders
set VSCodeExe=Code - Insiders.exe
set VSCodeDir=Microsoft VS Code Insiders
set VSCodeInternalName=code-insiders
) else if %FLAVOR%==exploration (
set VSCode=VSCodeExploration
set VSCodeExe=Code - Exploration.exe
set VSCodeDir=Microsoft VS Code Exploration
set VSCodeInternalName=code-exploration
) else (
set VSCode=VSCode
set VSCodeExe=Code.exe
set VSCodeDir=Microsoft VS Code
set VSCodeInternalName=code
)
set VSCodeExePath=%%LOCALAPPDATA%%\Programs\%VSCodeDir%\%VSCodeExe%
reg add "HKCR\*\shell\%VSCode%\command" /f /ve /t REG_EXPAND_SZ /d "\"%VSCodeExePath%\" \"%%1\" %ADDTIONAL_OPTS%" >NUL
reg add "HKCR\Applications\%VSCodeExe%\shell\open\command" /f /ve /t REG_EXPAND_SZ /d "\"%VSCodeExePath%\" \"%%1\" %ADDTIONAL_OPTS%" >NUL
reg add "HKCR\Directory\Background\shell\%VSCode%\command" /f /ve /t REG_EXPAND_SZ /d "\"%VSCodeExePath%\" \"%%V\" %ADDTIONAL_OPTS%" >NUL
reg add "HKCR\Directory\shell\%VSCode%\command" /f /ve /t REG_EXPAND_SZ /d "\"%VSCodeExePath%\" \"%%V\" %ADDTIONAL_OPTS%" >NUL
reg add "HKCR\Drive\shell\%VSCode%\command" /f /ve /t REG_EXPAND_SZ /d "\"%VSCodeExePath%\" \"%%V\" %ADDTIONAL_OPTS%" >NUL
@espresso3389
Copy link
Author

On certain machines, Chromium and its derivatives like Electron may cause problems and only the cure is to add --disable-gpu on its launching command line. For launch shortcuts, it's relatively easy but if it comes to context menu or file associations, it get more complex and we need such script to do it automatically.

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