Skip to content

Instantly share code, notes, and snippets.

@dangh
Created January 22, 2017 09:00
Show Gist options
  • Save dangh/ed9c0002bf46e3c69496386eca539a6e to your computer and use it in GitHub Desktop.
Save dangh/ed9c0002bf46e3c69496386eca539a6e to your computer and use it in GitHub Desktop.
Open folders and files with Sublime Text 3 from Windows Explorer context menu
@echo off
echo Put this file in the same folder as sublime_text.exe
echo Need to run as administrator
SET AppKey=Sublime Text
SET AppTitle=Open with ^&Sublime Text
SET AppPath=%~dp0sublime_text.exe
SET AppIcon=%AppPath%,0
:: right click on file
@REG ADD "HKEY_CLASSES_ROOT\*\shell\%AppKey%" /ve /f /d "%AppTitle%"
@REG ADD "HKEY_CLASSES_ROOT\*\shell\%AppKey%" /v "Icon" /f /d "%AppIcon%"
@REG ADD "HKEY_CLASSES_ROOT\*\shell\%AppKey%\command" /ve /f /d "%AppPath% \"%%1\""
:: right click on folder
@REG ADD "HKEY_CLASSES_ROOT\Directory\shell\%AppKey%" /ve /f /d "%AppTitle%"
@REG ADD "HKEY_CLASSES_ROOT\Directory\shell\%AppKey%" /v "Icon" /f /d "%AppIcon%"
@REG ADD "HKEY_CLASSES_ROOT\Directory\shell\%AppKey%\command" /ve /f /d "%AppPath% \"%%1\""
:: right click on folder background
@REG ADD "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppKey%" /ve /f /d "%AppTitle%"
@REG ADD "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppKey%" /v "Icon" /f /d "%AppIcon%"
@REG ADD "HKEY_CLASSES_ROOT\Directory\Background\shell\%AppKey%\command" /ve /f /d "%AppPath% \"%%v"
:: right click on drive
@REG ADD "HKEY_CLASSES_ROOT\Drive\shell\%AppKey%" /ve /f /d "%AppTitle%"
@REG ADD "HKEY_CLASSES_ROOT\Drive\shell\%AppKey%" /v "Icon" /f /d "%AppIcon%"
@REG ADD "HKEY_CLASSES_ROOT\Drive\shell\%AppKey%\command" /ve /f /d "%AppPath% \"%%1"
echo Done
echo Press any key to exit...
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment