forked from loo2k/Sublime-Text-Portable-Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSublime-Text-Portable-Tool-win8.bat
150 lines (72 loc) · 2.25 KB
/
Sublime-Text-Portable-Tool-win8.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
@echo OFF
title Sublime Text 便携版工具包
echo.
echo. Sublime Text 便携版工具包 说 明 @LOO2K
echo -----------------------------------------------------------------------
echo 操作序号:
echo 1: 添加 Sublime Text 到系统右键菜单;
echo 2: 卸载 Sublime Text 右键菜单;
echo 3: 注册扩展名; (扩展名列表请存放至同目录的 ext.txt 文件中)
echo 4: 卸载扩展名:
echo 5: 退出;
echo.
echo 注意事项:
echo 1. 请将此脚本复制到 Sublime Text 的文件夹;
echo 2. 确保 Sublime Text 的可执行文件名为 sublime_text.exe;
echo 3. 请将需要绑定的扩展名保存到同目录 ext.txt 文件中;(每行一个扩展名)
echo.
echo -----------------------------------------------------------------------
::http://www.computerhope.com/forum/index.php?topic=54333.0
setlocal
cd /d %~dp0
:begin
Set /p u=输入操作序号并按 Enter 键:
If "%u%" == "1" Goto regMenu
If "%u%" == "2" Goto unregMenu
If "%u%" == "3" Goto st2file
If "%u%" == "4" Goto unst2file
If "%u%" == "5" exit
If "%u%" == "" Goto begin
:regMenu
reg add "HKCR\*\shell\Sublime Text 2" /ve /d "Open With Sublime Text" /f
reg add "HKCR\*\shell\Sublime Text 2\command" /ve /d "%cd%\sublime_text.exe ""%%1""" /f
echo.
echo 已成功注册右键菜单
echo.
Goto begin
:unregMenu
reg delete "HKCR\*\shell\Sublime Text 2" /f
echo.
echo 已成功卸载右键菜单
echo.
Goto begin
:st2file
reg add "HKCR\st2file" /ve /d "文本文档" /f
reg add "HKCR\st2file\DefaultIcon" /ve /d "%cd%\sublime_text.exe" /f
reg add "HKCR\st2file\shell\open\command" /ve /d "%cd%\sublime_text.exe ""%%1""" /f
For /F "eol=;" %%e in (ext.txt) Do (
Rem echo %%e
(for /f "skip=2 tokens=1,2,* delims= " %%a in ('reg query "HKCR\.%%e" /ve') do (
If NOT "%%c" == "st2file" (
reg add "HKCR\.%%e" /v "st2_backup" /d "%%c" /f
)
))
assoc .%%e=st2file
)
echo.
echo 已成功注册扩展名
echo.
Goto begin
:unst2file
reg delete "HKCR\st2file" /f
For /F "eol=;" %%e in (ext.txt) Do (
Rem echo %%e
(for /f "skip=2 tokens=1,2,* delims= " %%a in ('reg query "HKCR\.%%e" /v "st2_backup"') do (
reg add "HKCR\.%%e" /ve /d "%%c" /f
reg delete "HKCR\.%%e" /V "st2_backup" /f
))
)
echo.
echo 已成功卸载扩展名
echo.
Goto begin