Skip to content

Instantly share code, notes, and snippets.

@sglbl
Last active May 28, 2024 07:30
Show Gist options
  • Select an option

  • Save sglbl/18bcd1c1c79c7ee32d5617e62db6017c to your computer and use it in GitHub Desktop.

Select an option

Save sglbl/18bcd1c1c79c7ee32d5617e62db6017c to your computer and use it in GitHub Desktop.
Open WSL with VSCode on Context Menu
:: ######################################- batch file from github.com/sglbl -##############################################
chcp 1254
@echo off
color 04
title Open VSCode with Wsl option in right click context menu
set "VscodeIcon=C:\Program Files\Microsoft VS Code\Code.exe"
:: ########################################################################################################################
set "KeyOfOpeningSpesificFolder=HKCR\Directory\shell\Wsl and VSCode"
REG ADD "%KeyOfOpeningSpesificFolder%" /v "Icon" /t REG_EXPAND_SZ /d "%VscodeIcon%"
REG ADD "%KeyOfOpeningSpesificFolder%" /ve /t REG_EXPAND_SZ /d "Open VSCode with Wsl"
REG ADD "%KeyOfOpeningSpesificFolder%\command" /ve /t REG_EXPAND_SZ /d "wsl --cd \"%%V\" code . "
:: #########################################################################################################################
set "KeyOfOpeningCurrentFolder=HKCR\Directory\Background\shell\Wsl and VSCode"
REG ADD "%KeyOfOpeningCurrentFolder%" /v "Icon" /t REG_EXPAND_SZ /d "%VscodeIcon%"
REG ADD "%KeyOfOpeningCurrentFolder%" /ve /t REG_EXPAND_SZ /d "Open VSCode with Wsl"
REG ADD "%KeyOfOpeningCurrentFolder%\command" /ve /t REG_EXPAND_SZ /d "wsl --cd \"%%V\" code ."
:: #########################################################################################################################
pause>nul
exit /b
@sglbl
Copy link
Author

sglbl commented May 28, 2024

Save the content as a .bat file.
Run as administrator.

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