Skip to content

Instantly share code, notes, and snippets.

@BitWizCoder-ol
Last active August 17, 2023 04:21
Show Gist options
  • Save BitWizCoder-ol/1de639edf21b3c8361b855726fded82c to your computer and use it in GitHub Desktop.
Save BitWizCoder-ol/1de639edf21b3c8361b855726fded82c to your computer and use it in GitHub Desktop.
Add and delete sublime text to the context menu.
@echo off
SET "st4Path=C:\Program Files\Sublime Text\sublime_text.exe"
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st4Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "\"%st4Path%\" \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st4Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "\"%st4Path%\" \"%%1\"" /f
rem add it for folder background
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st4Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "\"%st4Path%\" \"%%V\"" /f
pause
rem The main script by @mrchief, with a few adjustments made.
rem https://gist.github.com/mrchief/5628677?permalink_comment_id=2199554#gistcomment-2199554
@echo off
rem Define the Sublime Text path
SET "st4Path=C:\Program Files\Sublime Text\sublime_text.exe"
rem Delete registry entries for all file types
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /f
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /f
rem Delete registry entries for folders
@reg delete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text" /f
@reg delete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text\command" /f
rem Delete registry entries for folder background
@reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text" /f
@reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Sublime Text\command" /f
rem Pause to see the output
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment