-
Notifications
You must be signed in to change notification settings - Fork 4
/
Add GitHub-Desktop context menu.cmd
77 lines (65 loc) · 4.96 KB
/
Add GitHub-Desktop context menu.cmd
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
@echo off
SETLOCAL
:: Use double slash \\ for .reg compatibility
set "ghpath=%localappdata%\GitHubDesktop"
set "ghpath=%ghpath:\=\\%"
set ghbin=%ghpath%\\bin
set ghexe=%ghpath%\\GitHubDesktop.exe
set ghbat=%ghbin%\\github.bat
set noshell=%ghbin%\\noshell.vbs
mkdir "%ghbin%" >nul 2>&1
:: Remove previous context menu entries
reg delete "HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith" /f > nul 2>&1
reg delete "HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith" /f > nul 2>&1
:: Create noshell.vbs in order to run github.bat silently (to avoid cmd window popup)
echo 'from http://superuser.com/questions/140047 >"%noshell%"
echo If WScript.Arguments.Count ^>= 1 Then >>"%noshell%"
echo ReDim arr(WScript.Arguments.Count-1) >>"%noshell%"
echo For i = 0 To WScript.Arguments.Count-1 >>"%noshell%"
echo Arg = WScript.Arguments(i) >>"%noshell%"
echo If InStr(Arg, " ") ^> 0 or InStr(Arg, "&") ^> 0 Then Arg = chr(34) ^& Arg ^& chr(34) >>"%noshell%"
echo arr(i) = Arg >>"%noshell%"
echo Next >>"%noshell%"
echo RunCmd = Join(arr) >>"%noshell%"
echo CreateObject("Wscript.Shell").Run RunCmd, 0 , True >>"%noshell%"
echo End If >>"%noshell%"
:: Add GitHub context menu
set "rtmp=%temp%\github-context-menu--activate.reg"
echo Windows Registry Editor Version 5.00 >"%rtmp%"
echo: >>"%rtmp%"
echo ; Right click on explorer TREE >>"%rtmp%"
echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith] >>"%rtmp%"
echo @="Open with GitHub Desktop" >>"%rtmp%"
echo "Icon"="%ghexe%,0" >>"%rtmp%"
echo: >>"%rtmp%"
echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith\command] >>"%rtmp%"
echo @="WScript \"%noshell%\" \"%ghbat%\" open \"%%1\"" >>"%rtmp%"
echo: >>"%rtmp%"
echo ; Right click on explorer main area >>"%rtmp%"
echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith] >>"%rtmp%"
echo @="Open with GitHub Desktop" >>"%rtmp%"
echo "Icon"="%ghexe%,0" >>"%rtmp%"
echo: >>"%rtmp%"
echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith\command] >>"%rtmp%"
echo @="WScript \"%noshell%\" \"%ghbat%\" open \"%%V\"" >>"%rtmp%"
reg import "%rtmp%" > nul 2>&1
echo Enjoy your new menu entry:
echo:
echo ^ ^ ^+^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^+
echo ^ ^ ^|^ ^V^i^e^w^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^>^ ^|
echo ^ ^ ^|^ ^S^o^r^t^ ^B^y^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^>^ ^|
echo ^ ^ ^|^ ^G^r^o^u^p^ ^B^y^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^>^ ^|
echo ^ ^ ^|^ ^R^e^f^r^e^s^h^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^|
echo ^ ^ ^|^-^-^-^-^-^-^-^-^-^-^-^-^-^-^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