-
Notifications
You must be signed in to change notification settings - Fork 5
/
Setup.hta
417 lines (353 loc) · 16.3 KB
/
Setup.hta
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Context Menu Tools</title>
<meta name="description" content="Context Menu Tools">
<meta name="author" content="Ehryk Menze">
<HTA:APPLICATION
ID="1.0"
APPLICATIONNAME="Context Menu Tools"
BORDER="no"
CAPTION="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
SCROLL="no"
ICON="Images/ContextMenuTools.ico"
WINDOWSTATE="normal">
<SCRIPT LANGUAGE="VBScript">
Sub Window_onLoad
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
intLeft = (intHorizontal - 900) / 2
intTop = (intVertical - 600) / 2
window.resizeTo 900,600
window.moveTo intLeft, intTop
End Sub
</SCRIPT>
<style type="text/css">
html, body
{
height:100%;
}
.container
{
max-height: 100%;
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -1em;
overflow: visible;
}
.header
{
background-color: #333;
}
.menu
{
width: 100%;
}
.menu table
{
width:100%;
height:50px;
table-layout:fixed;
}
.menu td
{
text-align: center;
}
.menu td a
{
text-decoration: none;
color: white;
padding: 10.5px 11px;
}
.menu td a:visited
{
color: white;
}
.menu td a:hover
{
color: #fff;
background-color: #b00000;
}
.menu .current
{
color: #fff;
background-color: #800000;
}
h1
{
text-align: center;
color: white;
margin: 0px;
padding:10px;
}
h2, h3
{
font-weight: bold;
text-align: center;
margin: 10px;
}
h4
{
font-weight: bold;
}
.button
{
font: bold 16px "Helvetica Neue", Helvetica, Arial, clean, sans-serif !important;
border-radius: 5px;
display: block;
color: white;
padding: 4px 10px 4px;
white-space: nowrap;
text-decoration: none;
cursor: pointer;
background: #880000 url(/Images/button_overlay.png) repeat-x scroll 0 0;
border-style: none;
text-align: center;
overflow: visible;
margin:5px;
}
.button:hover,
.button:focus
{
background-position: 0 -50px;
color: white;
}
.button:active
{
background-position: 0 -100px;
}
.main div .left
{
width:40%;
float: left;
clear: right;
}
.main div .right
{
width: 59%;
float: left;
}
.footer, .push
{
clear: both;
height: 1em;
}
.footer
{
background:#333;
}
*
{
margin: 0;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Context Menu Tools v1.0</h1>
<div class="menu">
<table>
<tr>
<td><a id="a_home" href="#" onclick="changeTo('home');" class="current">Home</a></td>
<td><a id="a_default" href="#" onclick="changeTo('default');">Default Install</a></td>
<td><a id="a_custom" href="#" onclick="changeTo('custom');">Custom Install</a></td>
<td><a id="a_other" href="#" onclick="changeTo('other');">Other Tools</a></td>
<td><a id="a_about" href="#" onclick="changeTo('about');">About</a></td>
<td><a id="a_exit" href="#" onclick="exit();">Exit</a></td>
</tr>
</table>
</div>
</div>
<div id="main" class="main" role="main">
<div id="home" class="Section">
<br />
<img src="Images/AdministratorCommandPrompt.png" style="width:25%;float:left;margin:5px;" />
<img src="Images/SuperUserInstall.png" style="width:20%;float:left;clear:left;margin:5px;" />
<img src="Images/PowerShellDefault.png" style="width:30%;float:right;margin:5px;" />
Isn't it annoying to enter the command prompt, PowerShell, or Git Bash from your home directory each time? Or to have to go a directory down to right click a folder to "Open Git Bash Here"? How about browsing for the executable to "Run as Administrator", and then hitting "OK" at the slow User Account Control window? Context Menu Tools fixes that.
<br /><br />
This tool adds some helpful functionality to your Windows context menus - both the normal one, when right clicking on OR in a directory or drive, and more advanced options in the Extended context menu (shift + right click). When you select any option marked (Administrator) from the extended context menu, the UAC window is bypassed and you are brought quickly to an elevated command prompt or PowerShell window.
<br /><br />
Even further, the elevated command prompts are clearly marked. PowerShell's prompt is set to (User) (Location)>, and it writes the user in green or "Administrator" in red, and "Administrator: " is added to the window title. Administrator command prompts open with red foreground text.
I recommend starting with the default install.
<br /><br />
<div style="width:100%;text-align:center; font-weight: bold;">Written for Windows 7/Vista only - use in XP at your own risk</div><br />
<div style="width:100%;text-align:center;clear:both;"><input type="button" class="button" style="float:none;display:inline;margin-right:30px;" onclick="run('Default Install.bat');" value="Default Install" /><input type="button" class="button" style="float:none;display:inline;" onclick="run('SuperUser Install.bat');" value="SuperUser Install" /></div>
</div>
<div id="default" class="Section" style="display:none;">
<div class="left">
<h2 class="Title">Installers</h2>
<input type="button" class="button" onclick="run('Default Install.bat');" value="Default Install (Auto-Detect Git)" />
<input type="button" class="button" onclick="run('Default Installs\\Default Install Without Git.bat');" value="Default Install without Git" />
<br />
<input type="button" class="button" onclick="run('SuperUser Install.bat');" value="SuperUser Install (Auto-Detect Git)" />
<input type="button" class="button" onclick="run('Default Install\SuperUser Install Without Git.bat');" value="SuperUser Install without Git" />
<br /><br /><br /><br />
<h2 class="Title">Uninstall</h2>
<input type="button" class="button" onclick="run('Uninstall.bat');" value="Revert back to System Defaults" />
<input type="button" class="button" onclick="run('Other Tools\\UninstallAll.inf');" value="Remove Menu Entries Only" />
</div>
<div class="right">
<h2 class="Title">Default (Recommended)</h2>
This installs the following to your machine:
<br /><br />
<b>Normal Context Menu</b>
<img src="Images/DefaultInstall.png" style="float:right" />
<ul>
<li>Command Prompt Here</li>
<li>Git Bash Here</li>
<li>Start PowerShell Here</li>
</ul>
<b>Extended Context Menu</b> (Shift + Right Click)
<img src="Images/SuperUserInstall.png" style="float:right" />
<ul>
<li>Command Prompt Here</li>
<li>Command Prompt Here (Administrator)</li>
<li>Git Bash Here</li>
<li>Start PowerShell Here</li>
<li>Start PowerShell Here (Administrator)</li>
</ul><br />
It also forces powershell to keep the normal blue color scheme and window size when opened directly from the .exe.
<br /><br />
To uninstall, you can enter Control Panel -> Programs and select Context Menu Tools from the list of installed programs, or click one of the uninstall buttons. Revert puts in the entries replaced by the suite (Recommended), Remove Only does not.
</div>
</div>
<div id="custom" class="Section" style="display:none;">
<div class="left">
<h2 class="Title">Normal Context Menu</h2>
<input type="button" class="button" onclick="run('Custom Installs\\Command Prompt Here\\CommandPromptHere.inf');" value="Command Prompt Here" />
<input type="button" class="button" onclick="run('Custom Installs\\Command Prompt Here (Administrator)\\CommandPromptHereAdministrator.inf');" value="Command Prompt Here (Administrator)" />
<input type="button" class="button" onclick="run('Custom Installs\\Start PowerShell Here\\StartPowerShellHere.inf');" value="Start PowerShell Here" />
<input type="button" class="button" onclick="run('Custom Installs\\Start PowerShell Here (Administrator)\\StartPowerShellHereAdministrator.inf');" value="Start PowerShell Here (Administrator)" />
<input type="button" class="button" onclick="run('Custom Installs\\GitBashHere(x64).inf');" value="Git Bash Here (x64) (64 bit)" />
<input type="button" class="button" onclick="run('Custom Installs\\GitBashHere(x86).inf');" value="Git Bash Here (x86) (32 bit)" />
<h2 class="Title">Extended Context Menu</h2>
<input type="button" class="button" onclick="run('Custom Installs\\Command Prompt Here (Extended)\\CommandPromptHereExtended.inf');" value="Command Prompt Here" />
<input type="button" class="button" onclick="run('Custom Installs\\Command Prompt Here (Administrator) (Extended)\\CommandPromptHereAdministratorExtended.inf');" value="Command Prompt Here (Administrator)" />
<input type="button" class="button" onclick="run('Custom Installs\\Start PowerShell Here (Extended)\\StartPowerShellHereExtended.inf');" value="Start PowerShell Here" />
<input type="button" class="button" onclick="run('Custom Installs\\Start PowerShell Here (Administrator) (Extended)\\StartPowerShellHereAdministratorExtended.inf');" value="Start PowerShell Here (Administrator)" />
</div>
<div class="right">
<h2 class="Title">Custom</h2>
These installers add each item individually. Installing the extended version replaces the normal version, and vice versa (otherwise there would be duplicate entries).
<br /><br />
The extended context menu is accessed by holding down shift and right clicking. The installers marked Extended will only show when shift is pressed.
<br /><br />
To mimic the <b>Default Install</b>, choose:
<img src="Images/SuperUserInstall.png" style="float:right" />
<ul>
<li>Command Prompt Here</li>
<li>Command Prompt Here (Administrator)</li>
<li>Git Bash Here</li>
<li>Start PowerShell Here</li>
<li>Start PowerShell Here (Administrator)</li>
<li>Keep PowerShell Blue (in Other Tools)</li>
</ul><br />
To uninstall individually, go to Control Panel -> Programs and look under "Context Menu: XXX", then double click to uninstall. To uninstall everything, use the buttons in Default Install.
<br />
Everything here is available though .inf installers and a few batch files in the directories for advanced users.
</div>
</div>
<div id="other" class="Section" style="display:none;">
<div class="left">
<h2 class="Title">Installers</h2>
<input type="button" class="button" onclick="run('Other Tools\\KeepPowerShellBlue.inf');" value="Keep PowerShell Blue (Install)" />
<input type="button" class="button" onclick="run('Other Tools\\Keep PowerShell Blue.reg');" value="Keep PowerShell Blue (Registry)" />
<br />
<input type="button" class="button" onclick="run('Other Tools\\KeepCommandWindowScrollable.inf');" value="Keep cmd.exe Scrollable (Install)" />
<input type="button" class="button" onclick="run('Other Tools\\Keep Command Window Scrollable.reg');" value="Keep cmd.exe Scrollable (Registry)" />
<br />
<input type="button" class="button" onclick="run('Other Tools\\Always Show Open With\\AlwaysShowOpenWith.inf');" value="Always Show Open With..." />
<br />
<input type="button" class="button" onclick="run('Other Tools\\Return Default Git Context Menu Entries\\Bash(x64).inf');" value="Return Git Bash Here (x64) (64 bit)" />
<input type="button" class="button" onclick="run('Other Tools\\Return Default Git Context Menu Entries\\Bash(x86).inf');" value="Return Git Bash Here (x86) (32 bit)" />
</div>
<div class="right">
<h2 class="Title">Other Tools</h2>
These other useful tools for the context menu.<br /><br />
<img src="Images/PowerShellDefault.png" style="width:30%;float:right" />
<b>Keep PowerShell Blue</b> Forces PowerShell to retain the default colors and window size when launched directly from the .exe. By default these settings are stored in the .lnk file that is chosen from the Run command. If it is not installed, then PowerShell will look like cmd from the context menu. This may be done by running a .reg file (no uninstall option in Control Panel) or using the automatic installer (recommended).<br /><br />
<b>Always Show Open With...</b> Forces Windows to always display the Open With... menu entry when right clicking any file type. This sometimes shows duplicate entries, so it isn't part of the default install.<br /><br />
<b>Return Git ...</b> Replaces the default context menu items when Git was installed. They are replaced by the Default Install, and removed when uninstalled. By default, these are only available when right clicking a directory.<br /><br />
</div>
</div>
<div id="about" class="Section" style="display:none;">
<h2 class="Title">Context Menu Tools v1.0</h2>
<h3>Written by Eric Menze</h3><br /><br />
<div class="left" style="text-align:center">
<img src="Default Installs/Default Install (Git, x64) (64 bit)/cmd.ico" style="width:10%;">
<img src="Default Installs/Default Install (Git, x64) (64 bit)/cmdAdmin.ico" style="width:10%;%;">
<img src="Default Installs/Default Install (Git, x64) (64 bit)/PowerShell.ico" style="width:10%;">
<img src="Default Installs/Default Install (Git, x64) (64 bit)/PowerShellAdmin.ico" style="width:10%;">
<img src="Default Installs/Default Install (Git, x64) (64 bit)/Git.ico" style="width:15%;"><br />
<img src="Images/PowerShellDefault.png" style="width:80%;" />
</div>
<div class="right">
After using PowerShell and Git Bash a lot, I found it irritating to start in my home directory each time I opened a new prompt. Microsoft published their Elevation Power Toys, which would launch PowerShell and the command prompt from the context menus when right clicking drives and directories, but I found it lacking in a few features. What I wanted most was to right click the backgrounds of directories and drives, Git support, and other nitpicky details. This gave birth to this project.<br /><br />
I used the basic structure of their sample .INF files to write my own, with custom icons and more features. I alter the Administrator prompts to reflect the elevated status, customize the PowerShell prompts, set default colors, and most importantly add the ability to right click anywhere in a directory or drive.<br /><br />
If you find any bugs to report or would like to request additional features, please do so either on the <a href='https://github.com/Ehryk/ContextMenuTools'>Project Page at GitHub</a> or <a href="mailto:ehryk42@gmail.com">my email</a>. I'd be interested in any other commands that would be helpful in the context menu<br /><br />
</div>
</div>
</div>
<div class="push"></div>
</div>
<div class="footer">
</div>
<script type="text/javascript">
function changeTo(section) {
hideAll();
show(section);
return false;
}
function hideAll() {
hide("home");
hide("default");
hide("custom");
hide("other");
hide("about");
}
function show(id) {
var e = document.getElementById(id);
e.style.display = 'block';
e = document.getElementById('a_' + id);
e.className = 'current';
}
function hide(id) {
var e = document.getElementById(id);
e.style.display = 'none';
e = document.getElementById('a_' + id);
e.className = '';
}
function run(file) {
var cd, cmd, u = true;
shell = new ActiveXObject("WScript.Shell");
cd = shell.CurrentDirectory;
cmd = "runas /user:administrator /savecred \"" + cd + '\\' + file + "\"";
if (file.indexOf(".inf") != -1)
cmd = "rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 " + cmd;
if (file.indexOf(".reg") >= 0 || file.indexOf("Uninstall") >= 0)
u = false;
//alert(file);
//alert(cd);
var r = confirm("This will " + (u ? "install" : "run") + ": \"" + file + "\". " + (u ? "It can be uninstalled from the Programs section in the Control Panel." : ""));
if (r == true)
shell.Run(cmd, 1, false);
return false;
}
function exit() {
self.close();
}
</script>
</body>
</html>