Skip to content

Commit 92cef24

Browse files
authored
Add files via upload
1 parent 82b027a commit 92cef24

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

GitHubDesktop context menu.cmd

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
@echo off
2+
SETLOCAL
3+
4+
:: Use double slash \\ for .reg compatibility
5+
6+
set "ghpath=%localappdata%\GitHubDesktop"
7+
set "ghpath=%ghpath:\=\\%"
8+
9+
set ghbin=%ghpath%\\bin
10+
set ghexe=%ghpath%\\GitHubDesktop.exe
11+
set ghbat=%ghbin%\\github.bat
12+
13+
set noshell=%ghbin%\\noshell.vbs
14+
set regcascade=%ghbin%\\github-context-menu--activate-choice.cmd
15+
set regsingle=%ghbin%\\github-context-menu--activate.cmd
16+
set regremove=%ghbin%\\github-context-menu--remove.cmd
17+
18+
mkdir "%ghbin%" >nul 2>&1
19+
20+
21+
:: Create noshell.vbs in order to run github.bat silently (to avoid cmd window popup)
22+
echo 'from http://superuser.com/questions/140047 >"%noshell%"
23+
echo If WScript.Arguments.Count ^>= 1 Then >>"%noshell%"
24+
echo ReDim arr(WScript.Arguments.Count-1) >>"%noshell%"
25+
echo For i = 0 To WScript.Arguments.Count-1 >>"%noshell%"
26+
echo Arg = WScript.Arguments(i) >>"%noshell%"
27+
echo If InStr(Arg, " ") ^> 0 or InStr(Arg, "&") ^> 0 Then Arg = chr(34) ^& Arg ^& chr(34) >>"%noshell%"
28+
echo arr(i) = Arg >>"%noshell%"
29+
echo Next >>"%noshell%"
30+
echo RunCmd = Join(arr) >>"%noshell%"
31+
echo CreateObject("Wscript.Shell").Run RunCmd, 0 , True >>"%noshell%"
32+
echo End If >>"%noshell%"
33+
34+
35+
:: Create scripts to remove all context menu entries
36+
echo @echo off >"%regremove%"
37+
echo SETLOCAL >>"%regremove%"
38+
echo reg delete "HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith" /f 2^>nul >>"%regremove%"
39+
echo reg delete "HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith" /f 2^>nul >>"%regremove%"
40+
41+
42+
:: Create scripts to apply GitHub context menu
43+
echo @echo off >"%regsingle%"
44+
echo set "ghbin=%%~dp0" >>"%regsingle%"
45+
echo set "ghbin=%%ghbin:\=\\%%" >>"%regsingle%"
46+
echo set "ghexe=%%ghbin%%..\\GitHubDesktop.exe" >>"%regsingle%"
47+
echo set "ghbat=%%ghbin%%github.bat" >>"%regsingle%"
48+
echo set "noshell=%%ghbin%%noshell.vbs" >>"%regsingle%"
49+
echo: >>"%regsingle%"
50+
echo call "%%~dp0\github-context-menu--remove.cmd" >>"%regsingle%"
51+
echo: >>"%regsingle%"
52+
echo set rtmp="%%temp%%\github-context-menu--activate.reg" >>"%regsingle%"
53+
echo: >>"%regsingle%"
54+
echo echo Windows Registry Editor Version 5.00 ^>%%rtmp%% >>"%regsingle%"
55+
echo echo: ^>^>%%rtmp%% >>"%regsingle%"
56+
echo echo ; Right click on explorer TREE ^>^>%%rtmp%% >>"%regsingle%"
57+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith] ^>^>%%rtmp%% >>"%regsingle%"
58+
echo echo @="Open with GitHub Desktop" ^>^>%%rtmp%% >>"%regsingle%"
59+
echo echo "Icon"="%%ghexe%%,0" ^>^>%%rtmp%% >>"%regsingle%"
60+
echo echo: ^>^>%%rtmp%% >>"%regsingle%"
61+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith\command] ^>^>%%rtmp%% >>"%regsingle%"
62+
echo echo @="WScript \"%%noshell%%\" \"%%ghbat%%\" open \"%%%%1\"" ^>^>%%rtmp%% >>"%regsingle%"
63+
echo echo: ^>^>%%rtmp%% >>"%regsingle%"
64+
echo echo ; Right click on explorer main area ^>^>%%rtmp%% >>"%regsingle%"
65+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith] ^>^>%%rtmp%% >>"%regsingle%"
66+
echo echo @="Open with GitHub Desktop" ^>^>%%rtmp%% >>"%regsingle%"
67+
echo echo "Icon"="%%ghexe%%,0" ^>^>%%rtmp%% >>"%regsingle%"
68+
echo echo: ^>^>%%rtmp%% >>"%regsingle%"
69+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith\command] ^>^>%%rtmp%% >>"%regsingle%"
70+
echo echo @="WScript \"%%noshell%%\" \"%%ghbat%%\" open \"%%%%V\"" ^>^>%%rtmp%% >>"%regsingle%"
71+
echo: >>"%regsingle%"
72+
echo call reg import "%%rtmp%%" >>"%regsingle%"
73+
74+
75+
:: Create scripts to apply GitHub context menu
76+
echo @echo off >"%regcascade%"
77+
echo set "ghbin=%%~dp0" >>"%regcascade%"
78+
echo set "ghbin=%%ghbin:\=\\%%" >>"%regcascade%"
79+
echo set "ghexe=%%ghbin%%..\\GitHubDesktop.exe" >>"%regcascade%"
80+
echo set "ghbat=%%ghbin%%github.bat" >>"%regcascade%"
81+
echo set "noshell=%%ghbin%%noshell.vbs" >>"%regcascade%"
82+
echo: >>"%regcascade%"
83+
echo call "%%~dp0\github-context-menu--remove.cmd" >>"%regcascade%"
84+
echo: >>"%regcascade%"
85+
echo set rtmp="%%temp%%\github-context-menu--activate-choice.reg" >>"%regcascade%"
86+
echo: >>"%regcascade%"
87+
echo echo Windows Registry Editor Version 5.00 ^>%%rtmp%% >>"%regcascade%"
88+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
89+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
90+
echo echo ; Top Level item in menu (right click on a folder) ^>^>%%rtmp%% >>"%regcascade%"
91+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith] ^>^>%%rtmp%% >>"%regcascade%"
92+
echo echo "MUIVerb"="Open with GitHub Desktop" ^>^>%%rtmp%% >>"%regcascade%"
93+
echo echo "Icon"="%%ghexe%%,0" ^>^>%%rtmp%% >>"%regcascade%"
94+
echo echo "subcommands"="" ^>^>%%rtmp%% >>"%regcascade%"
95+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
96+
echo echo ; First item in submenu ^>^>%%rtmp%% >>"%regcascade%"
97+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith\shell\1GitHubDesktopOpenWith] ^>^>%%rtmp%% >>"%regcascade%"
98+
echo echo @="Open with GitHub Desktop" ^>^>%%rtmp%% >>"%regcascade%"
99+
echo echo "Icon"="%%ghexe%%,0" ^>^>%%rtmp%% >>"%regcascade%"
100+
echo echo "CommandFlags"=dword:00000040 ^>^>%%rtmp%% >>"%regcascade%"
101+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
102+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith\shell\1GitHubDesktopOpenWith\command] ^>^>%%rtmp%% >>"%regcascade%"
103+
echo echo @="WScript \"%%noshell%%\" \"%%ghbat%%\" open \"%%%%1\"" ^>^>%%rtmp%% >>"%regcascade%"
104+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
105+
echo echo ; Second item in submenu ^>^>%%rtmp%% >>"%regcascade%"
106+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith\shell\2ApplyMenu] ^>^>%%rtmp%% >>"%regcascade%"
107+
echo echo @="Keep GitHub explorer menu entry" ^>^>%%rtmp%% >>"%regcascade%"
108+
echo echo "Icon"="SHELL32.dll,296" ^>^>%%rtmp%% >>"%regcascade%"
109+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
110+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith\shell\2ApplyMenu\command] ^>^>%%rtmp%% >>"%regcascade%"
111+
echo echo @="WScript \"%%noshell%%\" \"%%ghbin%%github-context-menu--activate.cmd\"" ^>^>%%rtmp%% >>"%regcascade%"
112+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
113+
echo echo ; Third item in submenu ^>^>%%rtmp%% >>"%regcascade%"
114+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith\shell\3RemoveMenu] ^>^>%%rtmp%% >>"%regcascade%"
115+
echo echo @="Discard GitHub explorer menu entry" ^>^>%%rtmp%% >>"%regcascade%"
116+
echo echo "Icon"="SHELL32.dll,131" ^>^>%%rtmp%% >>"%regcascade%"
117+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
118+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\shell\GitHubDesktopOpenWith\shell\3RemoveMenu\command] ^>^>%%rtmp%% >>"%regcascade%"
119+
echo echo @="WScript \"%%noshell%%\" \"%%ghbin%%github-context-menu--remove.cmd\"" ^>^>%%rtmp%% >>"%regcascade%"
120+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
121+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
122+
echo echo ; Top Level item in menu (right click within a folder) ^>^>%%rtmp%% >>"%regcascade%"
123+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith] ^>^>%%rtmp%% >>"%regcascade%"
124+
echo echo "MUIVerb"="Open with GitHub Desktop" ^>^>%%rtmp%% >>"%regcascade%"
125+
echo echo "Icon"="%%ghexe%%,0" ^>^>%%rtmp%% >>"%regcascade%"
126+
echo echo "subcommands"="" ^>^>%%rtmp%% >>"%regcascade%"
127+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
128+
echo echo ; First item in submenu ^>^>%%rtmp%% >>"%regcascade%"
129+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith\shell\1GitHubDesktopOpenWith] ^>^>%%rtmp%% >>"%regcascade%"
130+
echo echo @="Open with GitHub Desktop" ^>^>%%rtmp%% >>"%regcascade%"
131+
echo echo "Icon"="%%ghexe%%,0" ^>^>%%rtmp%% >>"%regcascade%"
132+
echo echo "CommandFlags"=dword:00000040 ^>^>%%rtmp%% >>"%regcascade%"
133+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
134+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith\shell\1GitHubDesktopOpenWith\command] ^>^>%%rtmp%% >>"%regcascade%"
135+
echo echo @="WScript \"%%noshell%%\" \"%%ghbin%%\" open \"%%%%V\"" ^>^>%%rtmp%% >>"%regcascade%"
136+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
137+
echo echo ; Second item in submenu ^>^>%%rtmp%% >>"%regcascade%"
138+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith\shell\2ApplyMenu] ^>^>%%rtmp%% >>"%regcascade%"
139+
echo echo @="Keep GitHub explorer menu entry" ^>^>%%rtmp%% >>"%regcascade%"
140+
echo echo "Icon"="SHELL32.dll,296" ^>^>%%rtmp%% >>"%regcascade%"
141+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
142+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith\shell\2ApplyMenu\command] ^>^>%%rtmp%% >>"%regcascade%"
143+
echo echo @="WScript \"%%noshell%%\" \"%%ghbin%%github-context-menu--activate.cmd\"" ^>^>%%rtmp%% >>"%regcascade%"
144+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
145+
echo echo ; Third item in submenu ^>^>%%rtmp%% >>"%regcascade%"
146+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith\shell\3RemoveMenu] ^>^>%%rtmp%% >>"%regcascade%"
147+
echo echo @="Discard GitHub explorer menu entry" ^>^>%%rtmp%% >>"%regcascade%"
148+
echo echo "Icon"="SHELL32.dll,131" ^>^>%%rtmp%% >>"%regcascade%"
149+
echo echo: ^>^>%%rtmp%% >>"%regcascade%"
150+
echo echo [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\GitHubDesktopOpenWith\shell\3RemoveMenu\command] ^>^>%%rtmp%% >>"%regcascade%"
151+
echo echo @="WScript \"%%noshell%%\" \"%%ghbin%%github-context-menu--remove.cmd\"" ^>^>%%rtmp%% >>"%regcascade%"
152+
echo: >>"%regcascade%"
153+
echo call reg import "%%rtmp%%" >>"%regcascade%"
154+
155+
156+
call "%regcascade%"

0 commit comments

Comments
 (0)