Skip to content

Instantly share code, notes, and snippets.

@mansouryaacoubi
Last active July 3, 2017 00:51
Show Gist options
  • Save mansouryaacoubi/1735800189338119dc018b8e7e30f33f to your computer and use it in GitHub Desktop.
Save mansouryaacoubi/1735800189338119dc018b8e7e30f33f to your computer and use it in GitHub Desktop.
Add a Context Menu Item for Sublime Text 3 to your Windows Context Menu (Open File and Folders)
@echo off
net session >nul 2>&1
IF ERRORLEVEL 1 GOTO ERROR
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
REM add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
REM add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
echo Finished
GOTO EOF
:ERROR
echo Please start this batch with elevated rights.
echo (Right-click; "Run as Administrator")
goto EOF
:EOF
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment