无管理员权限下,如何在Windows将Sublime Text添加至右键菜单?
Absolutely doable! You don’t need admin rights to add Sublime Text to your Windows right-click menu—you just need to target your user-specific registry keys instead of the system-wide ones that require elevated permissions. Here’s a step-by-step guide to make it happen:
Step 1: Locate your Sublime Text executable path
Find wheresublime_text.exeis installed on your machine. If you installed it for your user only (not system-wide), it might be in something likeC:\Users\[YourUsername]\AppData\Local\Sublime Text\sublime_text.exe. If it’s a portable version, use the path to that executable. Copy this path—you’ll need it for the next step.Step 2: Create a custom registry file
Open Notepad (or any text editor) and paste the following code. Make sure to replace every instance ofC:\\Path\\To\\Your\\sublime_text.exewith the actual path you copied in Step 1 (note the double backslashes—Windows registry paths require them):Windows Registry Editor Version 5.00 ; Add "Open with Sublime Text" to files [HKEY_CURRENT_USER\Software\Classes\*\shell\Open with Sublime Text] @="Open with Sublime Text" "Icon"="\"C:\\Path\\To\\Your\\sublime_text.exe\",0" [HKEY_CURRENT_USER\Software\Classes\*\shell\Open with Sublime Text\command] @="\"C:\\Path\\To\\Your\\sublime_text.exe\" \"%1\"" ; Add "Open with Sublime Text" to folders (open folder in Sublime) [HKEY_CURRENT_USER\Software\Classes\Directory\shell\Open with Sublime Text] @="Open with Sublime Text" "Icon"="\"C:\\Path\\To\\Your\\sublime_text.exe\",0" [HKEY_CURRENT_USER\Software\Classes\Directory\shell\Open with Sublime Text\command] @="\"C:\\Path\\To\\Your\\sublime_text.exe\" \"%1\"" ; Add "Open with Sublime Text" to background (right-click empty space in folder) [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\Open with Sublime Text] @="Open with Sublime Text" "Icon"="\"C:\\Path\\To\\Your\\sublime_text.exe\",0" [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\Open with Sublime Text\command] @="\"C:\\Path\\To\\Your\\sublime_text.exe\" \"%V\""Step 3: Save and run the registry file
Save the file with a.regextension (e.g.,AddSublimeRightClick.reg). Make sure to select "All Files" from the "Save as type" dropdown in Notepad to avoid saving it as a.txtfile.Double-click the
.regfile. You’ll get a prompt asking if you want to add the entries to your registry—click "Yes". Since this modifies only your user-specific registry keys, no admin rights are required.Optional: Remove the entry later
If you ever want to remove Sublime Text from your right-click menu, create another.regfile with this code and run it:Windows Registry Editor Version 5.00 ; Remove "Open with Sublime Text" from files [-HKEY_CURRENT_USER\Software\Classes\*\shell\Open with Sublime Text] ; Remove "Open with Sublime Text" from folders [-HKEY_CURRENT_USER\Software\Classes\Directory\shell\Open with Sublime Text] ; Remove "Open with Sublime Text" from background [-HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\Open with Sublime Text]
内容的提问来源于stack exchange,提问作者elmigue017

