Skip to content

Instantly share code, notes, and snippets.

@Ambratolm
Last active February 23, 2022 19:06
Show Gist options
  • Save Ambratolm/e81531c1fba760571f881816eee6a59b to your computer and use it in GitHub Desktop.
Save Ambratolm/e81531c1fba760571f881816eee6a59b to your computer and use it in GitHub Desktop.
Open folders and files with Sublime Text 3 from Windows explorer context menu.
Rem ============================================================================
Rem ■ Open with Sublime Text 3
Rem ----------------------------------------------------------------------------
Rem Open folders and files with Sublime Text 3
Rem from Windows explorer context menu.
Rem ============================================================================
Rem ----------------------------------------------------------------------------
Rem ● Settings
Rem ----------------------------------------------------------------------------
Set AppName=SublimeText3
Set AppPath=C:\Program Files\Sublime Text 3\sublime_text.exe
Set AppIcon=%AppPath%,0
Rem ----------------------------------------------------------------------------
Set OpenFileText=Open with Sublime Text
Set OpenDirText=Open with Sublime Text
Set OpenCurrentDirText=Sublime Text Here
Rem ----------------------------------------------------------------------------
Set Title=Sublime Text 3 Shell Extension
Set Desc=Open folders and files with Sublime Text 3 from Windows explorer context menu.
Rem ----------------------------------------------------------------------------
Rem ● Title/Description
Rem ----------------------------------------------------------------------------
Title %Title%
Cls
@Echo Off
@Echo %Title%
@Echo %Desc%
@Echo.
Rem ----------------------------------------------------------------------------
Rem ● OpenFile-MenuItem
Rem ----------------------------------------------------------------------------
@Echo 1) Add "Open File" menu item:
Set OpenFileRegKey=HKEY_CLASSES_ROOT\*\shell\%AppName%
Rem ----------------------------------------------------------------------------
@Echo 1-A) Add menu text:
@Reg Add "%OpenFileRegKey%" /t REG_SZ /v "" /d "%OpenFileText%" /f
Rem ----------------------------------------------------------------------------
@Echo 1-B) Add menu icon:
@Reg Add "%OpenFileRegKey%" /t REG_EXPAND_SZ /v "Icon" /d "%AppIcon%" /f
Rem ----------------------------------------------------------------------------
@Echo 1-C) Add menu command:
@Reg Add "%OpenFileRegKey%\command" /t REG_SZ /v "" /d "%AppPath% \"%%1\"" /f
Rem ----------------------------------------------------------------------------
@Echo.
Rem ----------------------------------------------------------------------------
Rem ● OpenDirectory-MenuItem
Rem ----------------------------------------------------------------------------
@Echo 2) Add "Open Directory" menu item:
Set OpenDirRegKey=HKEY_CLASSES_ROOT\Directory\shell\%AppName%
Rem ----------------------------------------------------------------------------
@Echo 2-A) Add menu text:
@Reg Add "%OpenDirRegKey%" /t REG_SZ /v "" /d "%OpenDirText%" /f
Rem ----------------------------------------------------------------------------
@Echo 2-B) Add menu icon:
@Reg Add "%OpenDirRegKey%" /t REG_EXPAND_SZ /v "Icon" /d "%AppIcon%" /f
Rem ----------------------------------------------------------------------------
@Echo 2-C) Add menu command:
@Reg Add "%OpenDirRegKey%\command" /t REG_SZ /v "" /d "%AppPath% \"%%1\"" /f
@Echo.
Rem ----------------------------------------------------------------------------
Rem ● OpenLibraryFolder-MenuItem
Rem ----------------------------------------------------------------------------
@Echo 3) Add "Open Library Folder" menu text:
Set OpenLibFolderRegKey=HKEY_CLASSES_ROOT\LibraryFolder\shell\%AppName%
Rem ----------------------------------------------------------------------------
@Echo 3-A) Add menu text:
@Reg Add "%OpenLibFolderRegKey%" /t REG_SZ /v "" /d "%OpenDirText%" /f
Rem ----------------------------------------------------------------------------
@Echo 3-B) Add menu icon:
@Reg Add "%OpenLibFolderRegKey%" /t REG_EXPAND_SZ /v "Icon" /d "%AppIcon%" /f
Rem ----------------------------------------------------------------------------
@Echo 3-C) Add menu command:
@Reg Add "%OpenLibFolderRegKey%\command" /t REG_SZ /v "" /d "%AppPath% \"%%1\"" /f
Rem ----------------------------------------------------------------------------
@Echo.
Rem ----------------------------------------------------------------------------
Rem ● OpenCurrentDirectory-MenuItem
Rem ----------------------------------------------------------------------------
@Echo 3-A) Add "Open Current Directory" menu item:
Set OpenCurrentDirRegKey=HKEY_CLASSES_ROOT\Directory\Background\shell\%AppName%
Rem ----------------------------------------------------------------------------
@Echo Add menu text:
@Reg Add "%OpenCurrentDirRegKey%" /t REG_SZ /v "" /d "%OpenCurrentDirText%" /f
Rem ----------------------------------------------------------------------------
@Echo Add menu icon:
@Reg Add "%OpenCurrentDirRegKey%" /t REG_EXPAND_SZ /v "Icon" /d "%AppIcon%" /f
Rem ----------------------------------------------------------------------------
@Echo Add menu command:
@Reg Add "%OpenCurrentDirRegKey%\command" /t REG_SZ /v "" /d "%AppPath% \"%%v\"" /f
@Echo.
Rem ----------------------------------------------------------------------------
Rem ● OpenCurrentLibraryFolder-MenuItem
Rem ----------------------------------------------------------------------------
@Echo 4) Add "Open Current Library Folder" menu item:
Set OpenCurrentLibraryFolderRegKey=HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\%AppName%
Rem ----------------------------------------------------------------------------
@Echo 4-A) Add menu text:
@Reg Add "%OpenCurrentLibraryFolderRegKey%" /t REG_SZ /v "" /d "%OpenCurrentDirText%" /f
Rem ----------------------------------------------------------------------------
@Echo 4-B) Add menu icon:
@Reg Add "%OpenCurrentLibraryFolderRegKey%" /t REG_EXPAND_SZ /v "Icon" /d "%AppIcon%" /f
Rem ----------------------------------------------------------------------------
@Echo 4-C) Add menu command:
@Reg Add "%OpenCurrentLibraryFolderRegKey%\command" /t REG_SZ /v "" /d "%AppPath% \"%%v\"" /f
Rem ----------------------------------------------------------------------------
@Echo.
Rem ----------------------------------------------------------------------------
Rem ► End
Rem ----------------------------------------------------------------------------
@Echo Done.
@Echo.
Pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment