Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sublime text window下右键菜单。 保存为bat文件,放入sublimetext安装文件夹与sublime_text同级,双击执行即可。 能打开带空格文件夹下的文件。 注意:这个文件最好是复制并用记事本保存,直接下载的有可能存在换行问题导致不能正常使用。 支持文件夹右键;
@Echo Off
Title SublimeText 右键菜单维护
Pushd %~dp0
If "%PROCESSOR_ARCHITECTURE%"=="AMD64" (Set a="HKLM\SOFTWARE\Wow6432Node\SublimeText\sublimetext_backwnd" /v&Set b=%SystemRoot%\SysWOW64) Else (Set a="HKLM\SOFTWARE\SublimeText\sublimetext_backwnd" /v&Set b=%SystemRoot%\system32)
Rd "%b%\test_permission" >nul 2>nul
Md "%b%\test_permission" 2>nul||(Echo 请使用右键管理员身份运行&&Pause >nul&&Exit)
Rd "%b%\test_permission" >nul 2>nul
:START
CLS
Echo *=========================================================================*
Echo * *
Echo * [A]添加右键菜单 *
Echo * [D]删除右键菜单 *
Echo * [Q]退出 *
Echo * *
Echo *=========================================================================*
Echo *注意*请右键管理员权限运行:
Set /P Choice=请选择要进行的操作 (A/D/Q) ,然后按回车:
If /I "%Choice%"=="A" Goto ADD
If /I "%Choice%"=="D" Goto DEL
If /I "%Choice%"=="Q" Exit
Goto START
:END
CLS
Echo *=========================================================================*
Echo * *
Echo * 操作完成 *
Echo * [M]返回主菜单 *
Echo * [Q]退出 *
Echo * *
Echo *=========================================================================*
Set /P Choice=       请选择要进行的操作 (M/Q) ,然后按回车:
If /I "%Choice%"=="M" Goto :START
If /I "%Choice%"=="Q" Exit
:ADD
CLS
REG ADD HKEY_CLASSES_ROOT\*\shell\SublimeText /t REG_SZ /d SublimeText /f
REG ADD HKEY_CLASSES_ROOT\*\shell\SublimeText\Command /t REG_SZ /d "%cd%\sublime_text.exe \"%%1%%\"" /f
REG ADD HKEY_CLASSES_ROOT\Directory\shell\SublimeText /t REG_SZ /d SublimeText /f
REG ADD HKEY_CLASSES_ROOT\Directory\shell\SublimeText\Command /t REG_SZ /d "%cd%\sublime_text.exe -n \"%%1%%\"" /f
GOTO :END
:DEL
REG DELETE HKEY_CLASSES_ROOT\*\shell\SublimeText /f
REG DELETE HKEY_CLASSES_ROOT\Directory\shell\SublimeText /f
GOTO :END
@wulongqiu

This comment has been minimized.

Copy link

wulongqiu commented Jun 5, 2013

感谢!很好用。

@kaiye

This comment has been minimized.

Copy link

kaiye commented Jul 26, 2013

赞,如果能支持下目录的右键就更棒了。

@hizhengfu

This comment has been minimized.

Copy link
Owner Author

hizhengfu commented Dec 1, 2013

@kaiye 已经增加目录右键支持

@hackgyj

This comment has been minimized.

Copy link

hackgyj commented Jan 15, 2014

Win7下正常,XP下失效 _,感谢分享!

@ghost

This comment has been minimized.

Copy link

ghost commented Apr 17, 2014

非常好用,谢谢!
另外,提个小建议:增加判断当前目录下是否存在sublime_text.exe文件的判断,以免有些用户放错位置而使菜单失效。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.