Skip to content

Instantly share code, notes, and snippets.

@milnak
Last active August 15, 2024 18:08
Show Gist options
  • Save milnak/7be2fa766876d93aba5deb0585a66db5 to your computer and use it in GitHub Desktop.
Save milnak/7be2fa766876d93aba5deb0585a66db5 to your computer and use it in GitHub Desktop.
VSCode launcher: Better than just using "code" as it supports wildcards #vscode
@ECHO OFF
SETLOCAL
SET CodePath=
REM Visual Studio Code 64-bit user
CALL :GetUninstallPath "HKEY_CURRENT_USER" "{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1" "InstallLocation"
IF "%CodePath%" EQU "" (
REM Visual Studio Code 64-bit
CALL :GetUninstallPath "HKEY_LOCAL_MACHINE" "{EA457B21-F73E-494C-ACAB-524FDE069978}_is1" "InstallLocation"
IF "%CodePath%" EQU "" (
ECHO Can't find install location.
GOTO :EOF
)
)
:MAIN
IF /I "%~1" EQU "--version" (
CALL "%CodePath%\bin\code.cmd" --version
GOTO :EOF
)
IF /I "%~1" EQU "--help" (
CALL "%CodePath%\bin\code.cmd" --help
GOTO :EOF
)
IF /I "%~1" EQU "--list-extensions" (
CALL "%CodePath%\bin\code.cmd" --list-extensions --show-versions
GOTO :EOF
)
SET LIST=
:NEXTARG
IF "%~1"=="" GOTO :START
FOR %%i IN (%1) DO CALL :ADDARG "%%~fi"
SHIFT
GOTO :NEXTARG
:ADDARG
SET LIST=%LIST% %1
GOTO :EOF
:START
@echo on
CALL "%CodePath%\bin\code.cmd" --reuse-window %LIST%
@echo off
GOTO :EOF
:GetUninstallPath
SETLOCAL
FOR /F "skip=2 delims=" %%f IN ('REG.EXE QUERY "%~1\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%~2" /v "%~3"') DO SET P=%%f
ENDLOCAL & IF NOT "%P%" EQU "" SET CodePath=%p:~33%
REM echo Found %CodePath%
GOTO :EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment