Add Sublime Text to the right-click menu

Add Sublime Text to the right-click menu

1. Reference materials

Add Sublime Text3 to the right-click menu

2. How to solve it?

Super unpleasant operation

Since I uninstalled Notepad++, I have been using VS Code as my default text editor, but the startup speed of VS Code is still too slow. I recently switched to Sublime Text

I found a free installation version of Sublime Text on the Internet. It is particularly troublesome to open text files with unrecognized suffixes.


The following is the operation process

  1. Right-click the file and select [Open Method]

    image-20210116163834119

  2. It is not yet in the [Open Method], you can only choose [Find other applications on this computer]

    image-20210116164003665

  3. After going around, I finally found a way to open Sublime Text

    image-20210116164100888


Just imagine, if you need to do this every time, I vomit, I installed it. In fact, there is a solution. I saw on the blog that there is such a solution: execute the Bash command in the installation directory of Sublime Text

image-20210116164330885

Solution

  1. When I opened the installation directory of Sublime Text, I was so moved that I shed tears. There is such a user-friendly setting, and they just wrote it for me.

    image-20210116164440324

  2. The code of the Bash command is as follows, mainly to add some configuration information to the registry

    @ECHO OFF & PUSHD %~DP0 & TITLE
    >NUL 2>&1 REG.exe query "HKU\S-1-5-19" || (
        ECHO SET UAC = CreateObject^("Shell.Application"^) > "%TEMP%\Getadmin.vbs"
        ECHO UAC.ShellExecute "%~f0", "%1", "", "runas", 1 >> "%TEMP%\Getadmin.vbs"
        "%TEMP%\Getadmin.vbs"
        DEL /f /q "%TEMP%\Getadmin.vbs" 2>NUL
        Exit /b
    )
    SET /P ST=输入a添加右键菜单,输入d删除右键菜单:
    if /I "%ST%"=="a" goto Add
    if /I "%ST%"=="d" goto Remove
    :Add
    reg add "HKEY_CLASSES_ROOT\*\shell\Sublime Text"         /t REG_SZ /v "" /d "用 &Sublime Text 打开"   /f
    reg add "HKEY_CLASSES_ROOT\*\shell\Sublime Text"         /t REG_EXPAND_SZ /v "Icon" /d "%~dp0sublime_text.exe" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\Sublime Text\command" /t REG_SZ /v "" /d "%~dp0sublime_text.exe \"%%1\"" /f
     
    exit
    :Remove
    reg delete "HKEY_CLASSES_ROOT\*\shell\Sublime Text" /f
    exit
    
  3. Double-click to execute the .bat file, enter a, and then press Enter

    image-20210116164705683

  4. Kaisen

    image-20210116164834774

Guess you like

Origin blog.csdn.net/oneby1314/article/details/112759599