-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwin-sublime-rightkey.vbs
More file actions
42 lines (34 loc) · 2.03 KB
/
Copy pathwin-sublime-rightkey.vbs
File metadata and controls
42 lines (34 loc) · 2.03 KB
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
On Error Resume Next
' 1. Change this to your Sublime Text file path.
path = "D:\installedApps\Sublime Text Build 3143 x64\sublime_text.exe"
' 2. Optional - Change keyboard shortcut here, for example: "F" if you like.
shortcut = "Q"
Sub ElevateUAC
If Not WScript.Arguments.Named.Exists("elevated") Then
With CreateObject("Shell.Application")
.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """ /elevated", "", "runas", 1
WScript.Quit
End With
End If
End Sub
Call ElevateUAC
Set shell = CreateoBject("WScript.shell")
result = shell.Popup("Yes - Install" & vbCrLf & "No - Uninstall", 0, "Add " & chr(34) & "Open with Sublime Text" & chr(34) & " ?", vbYesNoCancel + vbQuestion)
If result = vbYes Then
shell.RegWrite "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\", "Open With Sublime Text(&" & shortcut & ")", "REG_SZ"
shell.RegWrite "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\Icon", path & ",0", "REG_EXPAND_SZ"
shell.RegWrite "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command\", path & " " & chr(34) & "%1" & chr(34), "REG_SZ"
shell.RegWrite "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text\", "Open With Sublime Text(&" & shortcut & ")", "REG_SZ"
shell.RegWrite "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text\Icon", path & ",0", "REG_EXPAND_SZ"
shell.RegWrite "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text\command\", path & " " & chr(34) & "%1" & chr(34), "REG_SZ"
ElseIf result = vbNo Then
shell.RegDelete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command\"
shell.RegDelete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\Icon"
shell.RegDelete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\"
shell.RegDelete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text\command\"
shell.RegDelete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text\Icon"
shell.RegDelete "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text\"
Else
WScript.Quit
End If